Skip to content

Instantly share code, notes, and snippets.

@rsky
Created July 26, 2010 21:57
Show Gist options
  • Save rsky/491322 to your computer and use it in GitHub Desktop.
Save rsky/491322 to your computer and use it in GitHub Desktop.
http://openpear.org/package/phpman 用zsh/bash補完関数
#compdef phpman
_search_word () {
_wanted test expl 'search_word' compadd \
$(command ls $(pear config-get data_dir)/phpman/php-chunked-xhtml \
| sed -e 's/\.html$//' \
| sed -e 's/^.*\.//' \
| sed -e 's/-/_/g' \
| sort | uniq)
}
_arguments \
'(-s --sync)'{-s,--sync}'[update php manual newest]' \
'(-h --help)'{-h,--help}'[shop help]' \
':search_word:_search_word'
_phpman_search_words=$(ls $(pear config-get data_dir)/phpman/php-chunked-xhtml \
| sed -e 's/\.html$//' \
| sed -e 's/^.*\.//' \
| sed -e 's/-/_/g' \
| sort | uniq)
_phpman()
{
COMPREPLY=( $( \
compgen -W "-s --sync -h --help $_phpman_search_words" \
${COMP_WORDS[COMP_CWORD]} \
) )
}
complete -F _phpman phpman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment