Add manually installed zsh autocompletion files

old-yadm
earnest ma 2021-07-04 22:20:47 -04:00
parent ee08882160
commit d2628bc73b
No known key found for this signature in database
GPG Key ID: 6B361FA81C5FB695
2 changed files with 248 additions and 0 deletions

View File

@ -0,0 +1,82 @@
#compdef ghq
function _ghq () {
local context curcontext=$curcontext state line
declare -A opt_args
local ret=1
_arguments -C \
'(-h --help)'{-h,--help}'[show help]' \
'(-v --version)'{-v,--version}'[print the version]' \
'1: :__ghq_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(get)
_arguments -C \
'(-u --update)'{-u,--update}'[Update local repository if cloned already]' \
'-p[Clone with SSH]' \
'--shallow[Do a shallow clone]' \
'(-l --look)'{-l,--look}'[Look after get]' \
'--vcs[Specify vcs backend for cloning]' \
'(-s --silent)'{-s,--silent}'[Clone or update silently]' \
'--no-recursive[Prevent recursive fetching]' \
'(-b --branch)'{-b,--branch}'[Specify branch name]' \
'(-P --parallel)'{-P,--parallel}'[Import parallely]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(list)
_arguments -C \
'(-e --exact)'{-e,--exact}'[Perform an exact match]' \
'--vcs[Specify vcs backend for matching]' \
'(-p --full-path)'{-p,--full-path}'[Print full paths]' \
'--unique[Print unique subpaths]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(root)
_arguments -C \
'--all[Show all roots]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(create)
_arguments -C \
'--vcs[Specify vcs backend explicitly]' \
'(-)*:: :->null_state' \
&& ret=0
;;
(help|h)
__ghq_commands && ret=0
;;
esac
;;
esac
return ret
}
__ghq_repositories () {
local -a _repos
_repos=( ${(@f)"$(_call_program repositories ghq list --unique)"} )
_describe -t repositories Repositories _repos
}
__ghq_commands () {
local -a _c
_c=(
'get:Clone/sync with a remote repository'
'list:List local repositories'
'create:Create a new repository'
"root:Show repositories' root"
'help:Show a list of commands or help for one command'
)
_describe -t commands Commands _c
}
_ghq "$@"

View File

@ -0,0 +1,166 @@
#compdef yadm
# This completion tries to fallback to git's completion for git commands.
zstyle -T ':completion:*:yadm:argument-1:descriptions:' format && \
zstyle ':completion:*:yadm:argument-1:descriptions' format '%d:'
zstyle -T ':completion:*:yadm:*:yadm' group-name && \
zstyle ':completion:*:yadm:*:yadm' group-name ''
_yadm-alt() {
return 0
}
_yadm-bootstrap() {
return 0
}
_yadm-clone() {
_arguments \
'(--bootstrap --no-bootstrap)--bootstrap[force bootstrap, without prompt]' \
'(--bootstrap --no-bootstrap)--no-bootstrap[prevent bootstrap, without prompt]' \
'-f[force overwrite of existing repository]' \
'-w[yadm work tree path]: :_files -/'
local curcontext="${curcontext%:*:*}:git:"
words=("git" "${words[@]}") CURRENT=$((CURRENT + 1)) service=git _git
}
_yadm-config() {
# TODO: complete config names
}
_yadm-decrypt() {
_arguments \
'-l[list files]'
}
_yadm-encrypt() {
return 0
}
_yadm-enter() {
_arguments \
':command: _command_names -e' \
'*::arguments: _normal'
}
_yadm-git-crypt() {
# TODO: complete git-crypt options
}
_yadm-help() {
return 0
}
_yadm-init() {
_arguments \
'-f[force overwrite of existing repository]' \
'-w[work tree path]: :_files -/'
}
_yadm-list() {
_arguments \
'-a[list all tracked files]'
}
_yadm-perms() {
return 0
}
_yadm-transcrypt() {
integer _ret=1
_call_function _ret _transcrypt
return _ret
}
_yadm-upgrade() {
_arguments \
'-f[force deinit of submodules]' \
': '
}
_yadm-version() {
return 0
}
_yadm_commands() {
local -a commands=(
alt:'create links for alternates'
bootstrap:'execute bootstrap'
clone:'clone an existing yadm repository'
config:'configure an yadm setting'
decrypt:'decrypt files'
encrypt:'encrypt files'
enter:'run sub-shell with GIT variables set'
git-crypt:'run git-crypt commands for the yadm repository'
gitconfig:'run the git config command'
help:'display yadm help information'
init:'initialize an empty yadm repository'
list:'list files tracked by yadm'
perms:'fix perms for private files'
transcrypt:'run transcrypt commands for the yadm repository'
upgrade:'upgrade legacy yadm paths'
version:'show yadm version'
)
local oldcontext="$curcontext"
local curcontext="${curcontext%:*:*}:git:"
words=("git" "${words[-1]}") CURRENT=2 service=git _git
curcontext="$oldcontext"
_describe -t yadm "yadm commands" commands
return 0
}
_yadm() {
local curcontext=$curcontext state state_descr line
declare -A opt_args
_arguments -C \
'(-Y --yadm-dir)'{-Y,--yadm-dir}'[override the standard yadm directory]: :_files -/' \
'--yadm-data[override the standard yadm data directory]: :_files -/' \
'--yadm-repo[override the standard repo path]: :_files -/' \
'--yadm-config[override the standard config path]: :_files -/' \
'--yadm-encrypt[override the standard encrypt path]: :_files -/' \
'--yadm-archive[override the standard archive path]: :_files -/' \
'--yadm-bootstrap[override the standard bootstrap path]: :_files' \
'--help[display yadm help information]' \
'--version[show yadm version]' \
'(-): :->command' \
'(-)*:: :->option-or-argument' && return
local -a repo_args
(( $+opt_args[--yadm-repo] )) && repo_args+=(--yadm-repo "$opt_args[--yadm-repo]")
(( $+opt_args[--yadm-data] )) && repo_args+=(--yadm-data "$opt_args[--yadm-data]")
local -x GIT_DIR="$(_call_program gitdir yadm "${repo_args[@]}" introspect repo)"
[[ -z "$GIT_DIR" ]] && return 1
integer _ret=1
case $state in
(command)
_yadm_commands && _ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:yadm-${words[1]}:
if ! _call_function _ret _yadm-${words[1]}; then
# Translate gitconfig to use the regular completion for config
[[ ${words[1]} = "gitconfig" ]] && words[1]=config
words=("git" "${(@)words}")
CURRENT=$(( CURRENT + 1 ))
curcontext=${curcontext%:*:*}:git:
service=git _git && _ret=0
fi
;;
esac
return _ret
}
(( $+functions[_git] )) && _yadm