godocの zsh補完
Emacsからは helmインタフェースで調べられますが、端末で調べる際に
補完が効かなかったので書いてみました
コード
#compdef godoc local -a go_packages go_packages=("builtin") for dir in $GOROOT $(perl -wle 'print $_ for split q{:}, $ENV{GOPATH}') do pkgdir="$dir/pkg" if [ -d $pkgdir ]; then packages=$(find $pkgdir -name "*.a" \ | perl -wlp -e "s{$pkgdir/(?:(?:obj|tool)/)?[^/]+/}{} and s{\\.a\$}{}") go_packages=($packages $go_packages) fi done _arguments -n : \ '(-ex)-ex=[show examples in command line mode]:bool:(true false)' \ '(-goroot)-goroot=[Go root directory]:rootdir:_files -/' \ '(-html)-html=[print HTML in command-line mode]:bool:(true false)' \ '(-index)-index=[enable search index]:bool:(true false)' \ '(-index_files)-index_files=[glob pattern specifying index files]' \ '(-index_throttle)-index_throttle=[index throttle value]' \ '(-links)-links=[link identifiers to their declarations]:bool:(true false)' \ '(-maxresults)-maxresults=[maximum number of full text search results shown]' \ '(-notes)-notes=[regular expression matching note markers to show]' \ '(-play)-play=[enable playground in web interface]:bool:(true false)' \ '(-q)-q=[arguments are considered search queries]:boold:(true false)' \ '(-server)-server=[webserver address for command line searches]' \ '(-src)-src=[print (exported) source in command-line mode]:bool:(true false)' \ '(-tabwidth)-tabwidth=[tab width]' \ '(-templates)-templates=[directory containing alternate template files]:tempdir:_files -/' \ '(-testdir)-testdir=[Go root subdirectory for testing only]:testdir:_files -/' \ '(-timestamps)-timestamps=[show timestamps with directory listings]:bool:(true false)' \ '(-url)-url=[print HTML for named URL]' \ '(-v)-v=[verbose mode]:bool:(true false)' \ '(-write_index)-write_index=[write index to a file]:bool:(true false)' \ '(-zip)-zip=[zip file providing the file system to serve]' \ '*:packages:'"($go_packages)" # Local Variables: # mode: Shell-Script # sh-indentation: 2 # indent-tabs-mode: nil # sh-basic-offset: 2 # End: # vim: ft=zsh sw=2 ts=2 et
おわりに
問題があればコメント等でお知らせください