Zsh plugin to inject a git hash into your current command line.
This plugin requires fzf
to be installed
and available in your $PATH
.
Are you a ZSH and Git user? Do you love fzf? Do you often find yourself needing to copy/paste a git hash from your git history to your command line? This plugin is for you!
Without this plugin, the workflow is painful:
- You run git log, possibly with
--all
or a branch name to find the commit you need. - You copy the hash somehow. This might involve using your terminal's copy mode, which is often not straightforward, or reaching out for your mouse.
- You paste the hash into your command line.
With this plugin, the worfklow is keyboard-centric:
- Start typing your command, e.g.
git cherry-pick
orgit show
. - Press
^X^G
(Control-X Control-G). This will open an fzf window with your git history. - Select the commit you want to inject.
Of course, this plugin relies on git log
to get the list of commits to choose
from. If you need to add extra options or arguments to the git log
command,
you can type them after your git command, then move the cursor left to them
before pressing ^X^G
.
The plugin will then remove the extra options and arguments, and use them along
with git log
.
git cherry-pick <your cursor is here>--all
When you press ^X^G
, the plugin will run git log --all
and open an fzf
window to allow you to select a commit.
This is not a feature of this plugin, but fzf
itself allows you to select
several entries by pressing tab before pressing enter.
I have installed this as an Antidote plugin, other plugin managers may work, if not feel free to submit a PR.
antidote install greg0ire/inject-git-hash