-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnox11-vim
More file actions
executable file
·54 lines (49 loc) · 1.24 KB
/
Copy pathnox11-vim
File metadata and controls
executable file
·54 lines (49 loc) · 1.24 KB
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
#!/bin/zsh
vim_cmd=`whence -p vim`
ipc_vim() {
local full_file_path=$1
local full_path=`readlink -f $1`
if [[ ! -z $full_path ]]; then
full_file_path=$full_path
fi
local sock_name=$2
local cmd=$3
local line=$4
echo $line $full_file_path $cmd | nc -U ${VIM9_NOX11_SOCK_DIR}/${sock_name}.sock
}
alt_vim() {
local cmd="/e"
local line="+0"
for arg in "$@"; do
if [[ $arg =~ '^\+[0-9]+' ]]; then
line=$arg
elif [[ $arg == "/v" ]]; then
cmd="/v"
elif [[ $arg == "/t" ]]; then
cmd="/t"
elif [[ $arg == "/e" ]]; then
cmd="/e"
else
local file=$arg
fi
done
if [[ ! -z $file ]]; then
if [[ "${file}" =~ "^--.*$" ]]; then
$vim_cmd $@
else
ipc_vim $file ${VIM9_NOX11_VIMSERVER} $cmd $line
if [[ -z $VIM_TERMINAL ]]; then
exit
fi
fi
else
echo "No new session allowed from vim terminal"
fi
}
if [[ "$@" =~ '^.*\/(COMMIT_EDITMSG|TAG_EDITMSG)$' ]]; then
VIM9_NOX11_VIMSERVER='' $vim_cmd $@
elif [[ -z $VIM9_NOX11_VIMSERVER ]]; then
VIM9_NOX11_VIMSERVER=VIM`date +%s` $vim_cmd $@
else
alt_vim $@
fi