From ebdd5a9320e7f4e989c42aa417c3e95076fe25a0 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Thu, 27 Oct 2016 16:33:59 +1100 Subject: [PATCH] Added zsh completion support :D --- .stow-rename | 1 + config/zsh/functions/_dots | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 config/zsh/functions/_dots diff --git a/.stow-rename b/.stow-rename index 8431b0a..51f56dd 100644 --- a/.stow-rename +++ b/.stow-rename @@ -1 +1,2 @@ +config => .config local => .local diff --git a/config/zsh/functions/_dots b/config/zsh/functions/_dots new file mode 100644 index 0000000..22b2c78 --- /dev/null +++ b/config/zsh/functions/_dots @@ -0,0 +1,34 @@ +#compdef dots +: ${DOTFILES:=~/dotfiles} +local context state state_descr line +typeset -A opt_args + +local repo +local -a commands repos new_repos +commands=( + bootstrap:'set up initial dotfiles on a new system' + clone:'download dotfiles packages over Git' + fetch:'retrieve updates to your packages' + link:'install downloaded packages into your ~' + status:'check whether your packages have changes' +) +if ! _retrieve_cache dots-repositories; then + repos=($(curl -s 'https://api.github.com/users/00dani/repos' | jq -r '.[].full_name | select(startswith("00dani/dot-")) | .[11:]')) + _store_cache dots-repositories repos +fi + +for repo in $repos; [[ -d $DOTFILES/$repo ]] || new_repos+=($repo) +_arguments '1:cmds:->cmds' '*:: :->args' +case $state in + cmds) _describe -t commands command commands ;; + args) case $line[1] in + bootstrap) _nothing ;; # no more arguments! + clone) + if (( $#new_repos )); then + _values -w package $new_repos + else + _message 'all known packages are already installed, you can still enter a git url manually' + fi ;; + fetch|link|st|status) _values -w package ${DOTFILES:-~/dotfiles}/*(/:t) ;; + esac ;; +esac