mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-09 02:24:03 +01:00
23 lines
No EOL
566 B
Bash
23 lines
No EOL
566 B
Bash
# Allow overriding API endpoint
|
|
: ${GITIGNORE_API_PRIMARY:="https://www.toptal.com/developers/gitignore/api"}
|
|
: ${GITIGNORE_API_FALLBACK:="https://www.gitignore.io/api"}
|
|
|
|
function _gi_curl() {
|
|
curl -sfL "$1/$2" || curl -sfL "$GITIGNORE_API_FALLBACK/$2"
|
|
}
|
|
|
|
function gi() {
|
|
local query="${(j:,:)@}"
|
|
_gi_curl "$GITIGNORE_API_PRIMARY" "$query" || return 1
|
|
}
|
|
|
|
_gitignoreio_get_command_list() {
|
|
_gi_curl "$GITIGNORE_API_PRIMARY" "list" | tr "," "\n"
|
|
}
|
|
|
|
_gitignoreio () {
|
|
compset -P '*,'
|
|
compadd -S '' $(_gitignoreio_get_command_list)
|
|
}
|
|
|
|
compdef _gitignoreio gi |