Skip to content

Commit

Permalink
zaw-launcher.zsh: experimental script to start zaw as command
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamuray committed Aug 10, 2011
1 parent adf41be commit ca9cd0d
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions zaw-launcher.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/zsh
#
# zaw-launcher.zsh
#
# launcher script to start zaw as command

# source zaw.zsh
zmodload zsh/parameter
local this_file="${funcsourcetrace[1]%:*}"
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

0 comments on commit ca9cd0d

Please sign in to comment.