Just a handy little tip.
The zsh git plugin offers a handy little function called ‘current_branch’. This will return the current git branch in the current git repository.
You can call zsh functions within commands by wrapping them with ‘$()’.
This helps me to reduce one of the little frustrations I have with git – specifying the branch name when pushing.
Now, I can just type this:
$ git push origin $(current_branch)
Of course, I’ve shortened this by creating an alias for current_branch called ‘cb’, so I just type:
$ git push origin $(cb)
The alias can be added to your .zshrc with the following code:
Simple and helpful.