Awesome
git-ignore
ZSH plugin. Generate .gitignore
with templates from gitignore.io
offline, taking the advantage of fzf
fuzzy finder,
bat
syntax highlighting and ZSH completion.
Feature
Basically, this plugin is an offline variant of gitignore.io with ZSH goodies:
- imitating template generation behavior of gitignore.io exactly
- fuzzy finder
fzf
selection with preview - ZSH completion
- pull/update templates from command line (no need to update this plugin)
Installation
Zplugin
The only ZSH plugin manager solves the time-consuming init for
nvm
, nodenv
, pyenv
, rvm
, rbenv
, thefuck
, fasd
, etc,
with its amazing async Turbo Mode.
zplugin ice pick'init.zsh' blockf
zplugin light laggardkernel/git-ignore
alias gi="git-ignore"
Update the plugin with
$ zplg update laggardkernel/git-ignore
Prezto
The only framework does optimizations in plugins with sophisticated coding skill:
- refreshing
.zcompdump
every 20h - compiling
.zcompdump
as bytecode in the background - caching init script for fasd
- saving
*env
startup time withinit - --no-rehash
forrbenv
,pyenv
,nodenv
- removing the horribly time-consuming
brew command
fromcommand-not-found
mkdir -p ${ZDOTDIR:-$HOME}/.zprezto/contrib 2>/dev/null
git clone https://github.com/laggardkernel/git-ignore.git ${ZDOTDIR:-$HOME}/.zprezto/contrib/git-ignore
Usage
$ alias gi="git-ignore"
# Depends on fzf
$ gi # then press <Enter>
# Separate params with spaces or commas
$ gi macos linux windows vim emacs >> ./.gitignore
# Overwrite existing .gitignore
$ gi macos,linux,windows vim emacs >| ./.gitignore
New CLI (v1.1.0+
)
❯ alias gi="git-ignore"
❯ gi -h
git-ignore 1.1.0 by laggardkernel <laggardkernel@gmail.com>
https://github.com/laggardkernel/git-ignore
Generates .gitignore files offline using templates from gitignore.io
Usage:
git-ignore [options]
git-ignore keyword1 keyword2 keyword3
Example:
git-ignore macos,linux,windows vim emacs >> ./.gitignore
Options:
-l, --list List available templates
-s, --search keyword Search template with keyword in filenames
-u, --update Init/Update local templates repo
-c, --clean Clean local gitignore templates repo
-h, --help Display this help screen
-v, --version Display version information and exit
❯ gi -l
1C,1C-Bitrix,A-Frame,Actionscript,Ada,Adobe,AdvancedInstaller,Agda,AL...
# omitted because it is too long
Total: 479
❯ gi -s py # then press <Tab> for completion
pycharm pycharm+all pycharm+iml pydev python
❯ gi -u
[Info] Updating gitignore repo...
Already up to date.
❯ gi -c
[Info] No available local gitignore repo
[Info] Use `gi -u` to init
Environment Variables
GI_TEMPLATE
: location for templates storage. It fallbacks to:
.git-ignore
directory under plugin's root folder${XDG_DATA_HOME}/git-ignore
(in case the script is not used as a ZSH plugin)$HOME/.local/share/git-ignore
Optional Dependencies
Default Keybindings for fzf
Keybind | Action |
---|---|
<kbd>Enter</kbd> | Confirm |
<kbd>Tab</kbd> | Toggle mark |
<kbd>?</kbd> | Toggle preview window |
<kbd>Ctrl</kbd> - <kbd>R</kbd> | Toggle selection |
<kbd>Alt</kbd> - <kbd>W</kbd> | Toggle preview wrap |
<kbd>Ctrl</kbd> - <kbd>K</kbd> / <kbd>P</kbd> | Selection up |
<kbd>Ctrl</kbd> - <kbd>J</kbd> / <kbd>N</kbd> | Selection down |
<kbd>Alt</kbd> - <kbd>K</kbd> / <kbd>P</kbd> | Preview up |
<kbd>Alt</kbd> - <kbd>J</kbd> / <kbd>N</kbd> | Preview down |
Todo
- Support all types of templates files from dvcs/gitignore
- Templates
- Patch
- Stack
- Order
- Remove unnecessary external dependencies:
,sed
awk
- ZSH completion
- Separate
compdef
into filefunctions/_git-ignore
- Separate
-
git
sub-commandgit ignore
- Options like
--list
,--update
,--search
, etc [ ] Configure the plugin withzstyle
- custom template storage location with
GI_TEMPLATE
- custom template storage location with
- Script file compatible with BASH
Related projects
wfxr/forgit: git-ignore was designed to be a feature of
it. And generating .gitignore
files offline was first introduced by me into it.
Later, git-ignore is separated from forgit
because of disagreement on implementation.
dvcs/gitignore: The largest collection of useful .gitignore
templates, maintained by https://www.gitignore.io.
simonwhitaker/gibo: Another .gitignore
generator using
templates from github/gitignore written in POSIX sh.
License
The MIT License (MIT)
Copyright (c) 2019 laggardkernel
Copyright (c) 2019 Wenxuan Zhang