git-highlight is a Zsh plugin that highlights your Git commands in real-time. It highlights valid and partially matched Git subcommands, and flags invalid ones right away.
See your Git commands highlighted instantly as you type for avoiding mistakes.
Zsh works on any platform including macOS, Linux, and Windows.
Tailor the plugin to your workflow with powerful customization options.
Typing:
git sta
will highlight git
in green and sta
in yellow,
hinting that you meant status
.
Once you complete it to:
git status
,
both words will be in green, confirming a valid command.
git stats
,
will highlight stats
in red.
git clone https://github.com/patriciosebastian/git-highlight.git ~/.git-highlight
.zshrc
file:
This will source the git-highlight
script on every new Zsh session, ensuring the highlighting feature is always active.
echo "source ~/.git-highlight/git-highlight.zsh" >> ~/.zshrc source ~/.zshrc
If you'd rather add it manually, just open your .zshrc
(located in your home directory) and append:
source ~/.git-highlight/git-highlight.zsh
source ~/.zshrc
again).From now on, every new Zsh terminal session will have real-time Git command highlighting enabled.
Your .zshrc
file is typically located in your home directory (~/.zshrc
). On macOS and Linux, you can access it by running:
cd ~ ls -a
If you see .zshrc
listed, you can open it with your favorite text editor. If it doesn't exist, you can create one:
touch ~/.zshrc
Windows users running Zsh in WSL will also find their .zshrc
file in the Linux home directory, e.g., ~/
within their WSL environment.
zplug "patriciosebastian/git-highlight"
Inside git-highlight.zsh
, you'll find:
**Git Commands:**
validGitCommands
array to add or remove recognized commands:
typeset -a validGitCommands=(git init commit push pull status checkout merge branch fetch rebase diff add log stash pop restore reset)
validGitCommands+=(blame cherry-pick worktree)
case "$word" in '&&'|'||'|';'|'&') expect_subcommand=false ;; esac
Feel Free to tweak these as needed for your workflow.