1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

home-manager: add zsh completion

Fixes #1075
This commit is contained in:
Anund 2021-01-03 00:07:14 +11:00 committed by Robert Helgesson
parent 73506f947c
commit 68dfc86173
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 56 additions and 0 deletions

View file

@ -0,0 +1,54 @@
#compdef home-manager
local state ret=1
_arguments \
'-A[attribute]:ATTRIBUTE:()' \
'-I[search path]:PATH:_files -/' \
'-b[backup files]:EXT:()' \
'--cores[cores]:NUM:()' \
'--keep-failed[keep failed]' \
'--keep-going[keep going]' \
'(-h --help)'{--help,-h}'[help]' \
'(-v --verbose)'{--verbose,-v}'[verbose]' \
'(-n --dry-run)'{--dry-run,-n}'[dry run]' \
'(-f --file)'{--file,-f}'[configuration file]:FILE:_files' \
'(-j --max-jobs)'{--max-jobs,-j}'[max jobs]:NUM:()' \
'--option[option]:NAME VALUE:()' \
'--show-trace[show trace]' \
'1: :->cmds' \
'*:: :->args' && ret=0
case "$state" in
cmds)
_values 'command' \
'help[help]' \
'edit[edit]' \
'build[build]' \
'switch[switch]' \
'generations[list generations]' \
'remove-generations[remove generations]' \
'expire-generations[expire generations]' \
'packages[managed packages]' \
'news[read the news]' \
'uninstall[uninstall]' && ret=0
;;
args)
case $line[1] in
remove-generations)
_values 'generations' \
$(home-manager generations | cut -d ' ' -f 5) && ret=0
;;
build|switch)
_arguments \
'--cores[cores]:NUM:()' \
'--keep-failed[keep failed]' \
'--keep-going[keep going]' \
'--max-jobs[max jobs]:NUM:()' \
'--option[option]:NAME VALUE:()' \
'--show-trace[show trace]'
;;
esac
esac
return ret

View file

@ -37,4 +37,6 @@ runCommand
install -D -m755 ${./completion.bash} \
$out/share/bash-completion/completions/home-manager
install -D -m755 ${./completion.zsh} \
$out/share/zsh/site-functions/_home-manager
''