From d2f210d70d214880b2573f8f0de7560a709448e6 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Fri, 16 Aug 2013 12:23:38 +0900 Subject: [PATCH] Implement sub-command completion for fish shell --- completions/pyenv.fish | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/completions/pyenv.fish b/completions/pyenv.fish index a1675bae..bf18b2a2 100644 --- a/completions/pyenv.fish +++ b/completions/pyenv.fish @@ -1,5 +1,22 @@ -function __fish_pyenv - pyenv commands +function __fish_pyenv_needs_command + set cmd (commandline -opc) + if [ (count $cmd) -eq 1 -a $cmd[1] = 'pyenv' ] + return 0 + end + return 1 end -complete -f -c pyenv -a '(__fish_pyenv)' +function __fish_pyenv_using_command + set cmd (commandline -opc) + if [ (count $cmd) -gt 1 ] + if [ $argv[1] = $cmd[2] ] + return 0 + end + end + return 1 +end + +complete -f -c pyenv -n '__fish_pyenv_needs_command' -a '(pyenv commands)' +for cmd in (pyenv commands) + complete -f -c pyenv -n "__fish_pyenv_using_command $cmd" -a "(pyenv completions $cmd)" +end