helm/config/zsh/completions/_dots
Henrik Lissner a75c64d04a
Rewrite to use flakes
This puts a hard dependency on 20.09, but that's to be expected.
2020-10-11 01:31:33 -04:00

36 lines
838 B
Plaintext
Executable file

#compdef nix
_dots_dispatch () {
local cmd="$@"
local offset=$#
CURRENT=$((CURRENT-$offset))
words=($cmd "${words[$((2 + offset)),-1]}")
_$cmd
}
_dots_command_list () {
dots | sed '1,/Available commands:/d' | awk '{ print $1 }'
}
_dots () {
local -a commands
IFS=$'\n' commands=($(_dots_command_list))
if (( CURRENT == 2 )); then
_describe -t commands "dots commands" commands
return
fi
integer ret=1
case ${words[2]} in
ch|channel) _dots_dispatch nix-channel ;;
b|build) _dots_dispatch nix-build ;;
ch|check) _dots_dispatch nix flake check ;;
sh|show) _dots_dispatch nix flake show ;;
-*) _dots_dispatch nix-env ;;
*) _message "Command not found: ${words[2]}" ;;
esac
return ret
}
_dots