aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/wsl/.config/zsh/.zshrc.d/99-wsl.zsh
blob: 5550aae22bb9dfb2cd38bfff6e123bbe3a19b682 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh

alias wsl='/mnt/c/Windows/system32/wsl.exe'
alias powershell.exe='/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe'
alias pwsh.exe='/mnt/c/Program Files/PowerShell/7/pwsh.exe'
alias winget='/mnt/c/Users/tobyv/AppData/Local/Microsoft/WindowsApps/winget.exe'
alias scoop='/mnt/c/Users/tobyv/scoop/shims/scoop'

zvm_vi_yank () {
	zvm_yank
	printf %s "${CUTBUFFER}" | win32yank.exe -i
	zvm_exit_visual_mode
}

zvm_vi_put_after () {
	local head= foot=
  local content=$(win32yank.exe -o)
	local offset=1
	if [[ ${content: -1} == $'\n' ]]
	then
		local pos=${CURSOR}
		for ((; $pos<$#BUFFER; pos++)) do
			if [[ ${BUFFER:$pos:1} == $'\n' ]]
			then
				pos=$pos+1
				break
			fi
		done
		if zvm_is_empty_line
		then
			head=${BUFFER:0:$pos}
			foot=${BUFFER:$pos}
		else
			head=${BUFFER:0:$pos}
			foot=${BUFFER:$pos}
			if [[ $pos == $#BUFFER ]]
			then
				content=$'\n'${content:0:-1}
				pos=$pos+1
			fi
		fi
		offset=0
		BUFFER="${head}${content}${foot}"
		CURSOR=$pos
	else
		if zvm_is_empty_line
		then
			head="${BUFFER:0:$((CURSOR-1))}"
			foot="${BUFFER:$CURSOR}"
		else
			head="${BUFFER:0:$CURSOR}"
			foot="${BUFFER:$((CURSOR+1))}"
		fi
		BUFFER="${head}${BUFFER:$CURSOR:1}${content}${foot}"
		CURSOR=$CURSOR+$#content
	fi
	zvm_highlight clear
	zvm_highlight custom $(($#head+$offset)) $(($#head+$#content+$offset))
}