Move into an external dir
[zsh.git] / .zsh / external / zaw / zaw-launcher.zsh
1 #!/bin/zsh
2 #
3 # zaw-launcher.zsh
4 #
5 # launcher script to start zaw as command
6
7 # source zaw.zsh
8 local this_file="$0"
9 local cur_dir="${this_file:A:h}"
10 source "${cur_dir}/zaw.zsh"
11
12
13 # parse arguments
14 do_eval=0
15
16 while getopts 'eh' opt; do
17 case "${opt}" in
18 e)
19 do_eval=1
20 ;;
21
22 h)
23 print \
24 "Usage: $0 [options] [source name]
25
26 Options:
27 -h show this help
28 -e eval result string
29 "
30 exit
31 ;;
32 esac
33 done
34
35 if (( OPTIND > 1 )); then
36 shift $(( OPTIND - 1 ))
37 fi
38
39 zaw_args=()
40 if [[ $# > 0 && "${zaw_sources[$1]}" != "" ]]; then
41 zaw_args+="${zaw_sources[$1]}"
42 fi
43
44
45 # use zle-line-init to start zaw right after vared
46 function zle-line-init() {
47 zle zaw "${(@)zaw_args}"
48
49 # return from vared
50 zle accept-line
51 }
52 zle -N zle-line-init
53
54 vared -c cmd
55
56 if (( do_eval )); then
57 eval "${cmd}"
58 else
59 print "${cmd}"
60 fi