1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/misc/rb_optparse.zsh
nobu 11ef87461a * lib/optparse.rb (OptionParser::Officious): separate completion
options from --help.  [ruby-dev:42690]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-07 13:31:11 +00:00

30 lines
793 B
Bash
Executable file

#!/bin/zsh
# Completion for zsh:
# (based on <http://d.hatena.ne.jp/rubikitch/20071002/zshcomplete>)
#
# (1) install this file,
#
# (2) load the script, and
# . ~/.zsh.d/rb_optparse.zsh
#
# (3) geneate completion files once.
# generate-complete-function/ruby/optparse COMMAND1
# generate-complete-function/ruby/optparse COMMAND2
#
generate-complete-function/ruby/optparse ()
{
local cmpl="_${1:t}"
mkdir -p "${ZSH_COMPLETION_DIR-$HOME/.zsh.d/Completion}"
$1 "--*-completion-zsh=${1:t}" > "${ZSH_COMPLETION_DIR-$HOME/.zsh.d/Completion}/$cmpl"
if [[ $(type -w "$cmpl") == "${cmpl}: function" ]]; then
unfunction "$cmpl"
autoload -U "$cmpl"
else
compinit "$cmpl"
fi
}
for cmd in "$@"; do
generate-complete-function/ruby/optparse "$cmd"
done