From 5f5c59a95feaf77db5f94cce56c6658fe78a3f62 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 11 Oct 2020 15:22:33 -0400 Subject: [PATCH] Fix zsh completion for bin/hey And remove unused commands from usage. --- bin/hey | 4 ---- config/zsh/completions/_dots | 35 ----------------------------------- config/zsh/completions/_hey | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 39 deletions(-) delete mode 100755 config/zsh/completions/_dots create mode 100755 config/zsh/completions/_hey diff --git a/bin/hey b/bin/hey index ac50b851..75aa211d 100755 --- a/bin/hey +++ b/bin/hey @@ -37,15 +37,11 @@ function main { echo echo "Available commands:" echo " init TODO" - echo " env (e) TODO" - echo " shell (sh) TODO" - echo " build (b) TODO" echo " upgrade (up) TODO" echo " rebuild (re) TODO" echo " rollback TODO" echo " gc TODO" echo " vm TODO" - echo " repl TODO" echo " push Push thie config to a remote NixOS system and rebuild it" echo " generations (gen) TODO" } diff --git a/config/zsh/completions/_dots b/config/zsh/completions/_dots deleted file mode 100755 index 6b5fc0f8..00000000 --- a/config/zsh/completions/_dots +++ /dev/null @@ -1,35 +0,0 @@ -#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 diff --git a/config/zsh/completions/_hey b/config/zsh/completions/_hey new file mode 100755 index 00000000..fd17b507 --- /dev/null +++ b/config/zsh/completions/_hey @@ -0,0 +1,35 @@ +#compdef hey + +_hey_dispatch () { + local cmd="$@" + local offset=$# + CURRENT=$((CURRENT-$offset)) + words=($cmd "${words[$((2 + offset)),-1]}") + _$cmd +} + +_hey_command_list () { + hey | sed '1,/Available commands:/d' | awk '{ print $1 }' +} + +_hey () { + local -a commands + IFS=$'\n' commands=($(_hey_command_list)) + + if (( CURRENT == 2 )); then + _describe -t commands "hey commands" commands + return + fi + integer ret=1 + case ${words[2]} in + ch|channel) _hey_dispatch nix-channel ;; + b|build) _hey_dispatch nix-build ;; + ch|check) _hey_dispatch nix flake check ;; + sh|show) _hey_dispatch nix flake show ;; + -*) _hey_dispatch nix-env ;; + *) _message "Command not found: ${words[2]}" ;; + esac + return ret +} + +_hey