Last active
December 15, 2015 18:09
-
-
Save kazuph/5301397 to your computer and use it in GitHub Desktop.
plenvのzsh補完をするためのScript。zshrcへ追加で使える。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_plenv() { | |
# cmdsという変数を定義 | |
local -a cmds | |
# カーソルが現在何番目のコマンドを入力しようとしてるのかがCURRENTに入ってる | |
# すでにplenvと打っているはずなので補完は2コマンド目から | |
# 3番目以降のコマンドを入力しようとしているときにはelseへ行く | |
if (( CURRENT == 2 ));then | |
compadd init rehash exec which version help global local install list versions list_modules install_cpanm available migrate_modules | |
elif [ $words[CURRENT-1] = 'local' -o $words[CURRENT-1] = 'global' -o $words[CURRENT-1] = 'migrate_modules' -o $words[CURRENT-2] = 'migrate_modules' ];then | |
# $wordsという配列に入力したコマンドが入っているのでそれを使ってパターンマッチ | |
# 現在インストールされているPerlをパースして変換候補に | |
compadd `plenv list | sed -e 's/\*//g' -e 's/ //g'` | |
fi | |
return 1; | |
} | |
# plenvというコマンドに関数_plenvを関連付け | |
compdef _plenv plenv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment