2016-10-27 01:33:59 -04:00
|
|
|
#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'
|
2023-12-05 03:55:50 -05:00
|
|
|
stow:'stow downloaded packages into your ~'
|
|
|
|
unstow:'unstow installed packages (cleans up their symlinks)'
|
|
|
|
restow:'unstow then stow installed packages (may be useful if package layout changed)'
|
2016-10-29 19:17:24 -04:00
|
|
|
pull:'fetch and apply package updates'
|
2016-10-27 01:33:59 -04:00
|
|
|
status:'check whether your packages have changes'
|
|
|
|
)
|
|
|
|
if ! _retrieve_cache dots-repositories; then
|
2021-07-14 19:18:45 -04:00
|
|
|
repos=($(curl -s -X GET "https://git.00dani.me/api/v1/orgs/dot/repos" -H "accept: application/json" | jq -r '.[].name'))
|
2016-10-27 01:33:59 -04:00
|
|
|
_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 ;;
|
2023-12-05 03:55:50 -05:00
|
|
|
fetch|*stow|pull|st|status) _values -w package $DOTFILES/*(/:t) ;;
|
2016-10-27 01:33:59 -04:00
|
|
|
esac ;;
|
|
|
|
esac
|