mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Merge f27c134264 into a79b37b954
This commit is contained in:
commit
6f89179f2c
1 changed files with 15 additions and 4 deletions
|
|
@ -1,12 +1,23 @@
|
|||
function gi() { curl -fLw '\n' https://www.toptal.com/developers/gitignore/api/"${(j:,:)@}" }
|
||||
# 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() {
|
||||
curl -sfL https://www.toptal.com/developers/gitignore/api/list | tr "," "\n"
|
||||
_gi_curl "$GITIGNORE_API_PRIMARY" "list" | tr "," "\n"
|
||||
}
|
||||
|
||||
_gitignoreio () {
|
||||
compset -P '*,'
|
||||
compadd -S '' `_gitignoreio_get_command_list`
|
||||
compadd -S '' $(_gitignoreio_get_command_list)
|
||||
}
|
||||
|
||||
compdef _gitignoreio gi
|
||||
compdef _gitignoreio gi
|
||||
Loading…
Add table
Add a link
Reference in a new issue