From 034f4919760fd832e4411eeb09bbc4fedcbad0e0 Mon Sep 17 00:00:00 2001 From: HOHOH134 <1992537+showchi@users.noreply.github.com> Date: Mon, 19 Jan 2026 16:31:44 +0800 Subject: [PATCH] gitignore plugin: switch API endpoint to gitignore.io CDN and update README --- plugins/gitignore/README.md | 4 ++-- plugins/gitignore/gitignore.plugin.zsh | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/plugins/gitignore/README.md b/plugins/gitignore/README.md index 23c7887cf..ea991a951 100644 --- a/plugins/gitignore/README.md +++ b/plugins/gitignore/README.md @@ -1,6 +1,6 @@ # gitignore -This plugin enables you the use of [gitignore.io](https://www.toptal.com/developers/gitignore) from the command line. You need an active internet connection. +This plugin enables you to use [gitignore.io](https://www.gitignore.io) from the command line. You need an active internet connection to fetch templates. The plugin uses the gitignore.io CDN endpoint to simplify access and improve reliability. To use it, add `gitignore` to the plugins array in your zshrc file: @@ -14,4 +14,4 @@ plugins=(... gitignore) * `gi [TEMPLATENAME]`: Show git-ignore output on the command line, e.g. `gi java` to exclude class and package files. -* `gi [TEMPLATENAME] >> .gitignore`: Appending programming language settings to your projects .gitignore. +* `gi [TEMPLATENAME] >> .gitignore`: Append the template rules to your project's `.gitignore` file. diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh index 2977f2426..a9f3f6453 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -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 () {