oh-my-zsh git plugin tip

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:

alias cb="current_branch"

Simple and helpful.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s