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 3271d61a9..a9f3f6453 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -1,12 +1,21 @@ -function gi() { curl -fLw '\n' https://www.toptal.com/developers/gitignore/api/"${(j:,:)@}" } +# gitignore plugin for oh-my-zsh +# Uses gitignore.io CDN endpoint +function _gi_curl() { + curl -sfL "https://www.gitignore.io/api/$1" +} + +function gi() { + local query="${(j:,:)@}" + _gi_curl "$query" || return 1 +} _gitignoreio_get_command_list() { - curl -sfL https://www.toptal.com/developers/gitignore/api/list | tr "," "\n" + _gi_curl "list" | tr "," "\n" } _gitignoreio () { compset -P '*,' - compadd -S '' `_gitignoreio_get_command_list` + compadd -S '' $(_gitignoreio_get_command_list) } -compdef _gitignoreio gi +compdef _gitignoreio gi \ No newline at end of file