forked from zsh-users/zaw
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathzaw-launcher.zsh
executable file
·60 lines (47 loc) · 901 Bytes
/
zaw-launcher.zsh
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
60
#!/bin/zsh
#
# zaw-launcher.zsh
#
# launcher script to start zaw as command
# source zaw.zsh
local this_file="$0"
local cur_dir="${this_file:A:h}"
source "${cur_dir}/zaw.zsh"
# parse arguments
do_eval=0
while getopts 'eh' opt; do
case "${opt}" in
e)
do_eval=1
;;
h)
print \
"Usage: $0 [options] [source name]
Options:
-h show this help
-e eval result string
"
exit
;;
esac
done
if (( OPTIND > 1 )); then
shift $(( OPTIND - 1 ))
fi
zaw_args=()
if [[ $# > 0 && "${zaw_sources[$1]}" != "" ]]; then
zaw_args+="${zaw_sources[$1]}"
fi
# use zle-line-init to start zaw right after vared
function zle-line-init() {
zle zaw "${(@)zaw_args}"
# return from vared
zle accept-line
}
zle -N zle-line-init
vared -c cmd
if (( do_eval )); then
eval "${cmd}"
else
print "${cmd}"
fi