Autocompletion plugin for ZSH that will complete git checkout
with a list of recently checked-out branches.
Inspired by the 'git lb' alias from https://ses4j.github.io/2020/04/01/git-alias-recent-branches/.
This plugin enhances the git checkout
command by providing autocompletion for recently checked-out branches. It helps you quickly switch between branches you have recently worked on.
When you type git checkout
and press <TAB>
, the plugin will provide a list of recently checked-out branches.
If you specify any non-default arguments or start typing a branch name, the original git completion will be used.
The top section shows the plugin in action when pressing <TAB>
.
The bottom section shows the regular completion when pressing s
then <TAB>
.
You can adjust the number of recently checked-out branches displayed by setting the _GIT_COMPLETION_LAST_BRANCHES_COUNT
variable in your .zshrc
file. The default value is 10.
_GIT_COMPLETION_LAST_BRANCHES_COUNT=15
-
Clone the repository into your custom plugins directory:
git clone https://github.com/lipner/better_git_checkout.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/better_git_checkout
-
Add the plugin to your
.zshrc
file:plugins=(... better_git_checkout)
-
Reload your
.zshrc
file:source ~/.zshrc
-
Clone the repository into a directory of your choice:
git clone https://github.com/lipner/better_git_checkout.git ~/better_git_checkout
-
Source the plugin in your
.zshrc
file:source ~/better_git_checkout/better_git_checkout.plugin.zsh
-
Reload your
.zshrc
file:source ~/.zshrc