Last active
February 11, 2022 17:40
-
-
Save whi-tw/e1ede8654707b1203d78c4e9d663f803 to your computer and use it in GitHub Desktop.
zsh plugin to add gh command completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh | |
# Add completions folder in $ZSH_CACHE_DIR | |
command mkdir -p "$ZSH_CACHE_DIR/completions" | |
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath) | |
# If the completion file does not exist, generate it and then source it | |
# Otherwise, source it and regenerate in the background | |
if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then | |
gh completion -s zsh >| "$ZSH_CACHE_DIR/completions/_gh" | |
source "$ZSH_CACHE_DIR/completions/_gh" | |
else | |
source "$ZSH_CACHE_DIR/completions/_gh" | |
gh completion -s zsh >| "$ZSH_CACHE_DIR/completions/_gh" &| | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment