Skip to content

Instantly share code, notes, and snippets.

@BaksiLi
Created August 12, 2023 06:54
Show Gist options
  • Save BaksiLi/3745465079978f76ade84d8cdc4780e1 to your computer and use it in GitHub Desktop.
Save BaksiLi/3745465079978f76ade84d8cdc4780e1 to your computer and use it in GitHub Desktop.
Zinit Install GitHub completion or Gist snippets
local GH_RAW_URL='https://raw.githubusercontent.com'
install_completion(){ zinit for as'completion' nocompile id-as"$1" is-snippet "$GH_RAW_URL/$2"; }
local GHG_RAW_URL='https://gist.githubusercontent.com'
install_gist_snippet() {
local url="$2"
if [[ $url != $GHG_RAW_URL* ]]; then
url="$GHG_RAW_URL/$url"
fi
if [[ $url != *raw ]]; then
url="${url://\//}/raw"
fi
zinit ice wait lucid id-as"$1"; zinit snippet "$url"
}
@BaksiLi
Copy link
Author

BaksiLi commented Aug 12, 2023

Example:

# Completion
install_completion 'docker-completion/_docker' 'docker/cli/master/contrib/completion/zsh/_docker'

# Snippet
install_gist_snippet 'BaksiLi/zinit-remove' 'BaksiLi/498c63a1cd12e3dd1f6b7426206c33ed'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment