2021-05-03 16:35:28 +02:00
|
|
|
# Autocompletion for the GitHub CLI (gh).
|
|
|
|
if (( $+commands[gh] )); then
|
2021-09-15 18:18:25 +02:00
|
|
|
ver="$(gh --version)"
|
|
|
|
ver_file="$ZSH_CACHE_DIR/gh_version"
|
2021-09-15 18:41:44 +02:00
|
|
|
comp_file="$ZSH_CACHE_DIR/completions/_gh"
|
|
|
|
|
|
|
|
mkdir -p "${comp_file:h}"
|
|
|
|
(( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
|
2021-09-15 18:18:25 +02:00
|
|
|
|
|
|
|
if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
|
|
|
|
gh completion --shell zsh >| "$comp_file"
|
|
|
|
echo "$ver" >| "$ver_file"
|
2021-05-03 16:35:28 +02:00
|
|
|
fi
|
2021-09-15 18:18:25 +02:00
|
|
|
|
|
|
|
declare -A _comps
|
2021-05-03 16:35:28 +02:00
|
|
|
autoload -Uz _gh
|
|
|
|
_comps[gh]=_gh
|
2021-09-15 18:18:25 +02:00
|
|
|
|
|
|
|
unset ver ver_file comp_file
|
2021-05-03 16:35:28 +02:00
|
|
|
fi
|
|
|
|
|