Add auto-completion for config command

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-10-15 20:41:43 +02:00
parent 3ed7de4a5d
commit 12c3ebc1d6
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 29 additions and 0 deletions

25
.zsh/complete/_config Normal file
View file

@ -0,0 +1,25 @@
#compdef _config config
set -eo pipefail
typeset -A opt_args
function _config() {
#set -x
_arguments -C \
'1:repo:->repos' \
'*::: :->args'
case "$state" in
repos)
local repos
repos=($(ls -1 "${HOME}/.cfg"))
_describe 'repos' repos
;;
args)
_dispatch git -default-
;;
*)
return 1
;;
esac
}

View file

@ -59,3 +59,7 @@ source ${HOME}/.zsh/peco.sh
## Clean PATH from duplicates ## Clean PATH from duplicates
export PATH=$(${HOME}/bin/path-dedup.py) export PATH=$(${HOME}/bin/path-dedup.py)
## Add custom auto-completions
export fpath=("${HOME}/.zsh/complete" $fpath)
compinit