gitignore plugin: switch API endpoint to gitignore.io CDN and update README

This commit is contained in:
HOHOH134 2026-01-19 16:31:44 +08:00
commit 034f491976
2 changed files with 7 additions and 9 deletions

View file

@ -1,18 +1,16 @@
# Allow overriding API endpoint
: ${GITIGNORE_API_PRIMARY:="https://www.toptal.com/developers/gitignore/api"}
: ${GITIGNORE_API_FALLBACK:="https://www.gitignore.io/api"}
# gitignore plugin for oh-my-zsh
# Uses gitignore.io CDN endpoint
function _gi_curl() {
curl -sfL "$1/$2" || curl -sfL "$GITIGNORE_API_FALLBACK/$2"
curl -sfL "https://www.gitignore.io/api/$1"
}
function gi() {
local query="${(j:,:)@}"
_gi_curl "$GITIGNORE_API_PRIMARY" "$query" || return 1
_gi_curl "$query" || return 1
}
_gitignoreio_get_command_list() {
_gi_curl "$GITIGNORE_API_PRIMARY" "list" | tr "," "\n"
_gi_curl "list" | tr "," "\n"
}
_gitignoreio () {