GIT bash cheats

When you install GIT you should also install the GIT bash completion with it. (On gentoo you just need to set the bash-completion USE flag when emerging git). This makes your life much easier. This can complete git commands like “git stat[TAB]” to “git status”. Additionally it offers the GIT bash function __get_ps1 for your command prompt. You can integrate this into your “PS1” variable to show the current branch of your working dir on your command prompt. That’s just great, isn’t it?

Add this to your ~/.bashrc to activate the GIT bash completion and the new command prompt.

# load git bash completion
source /usr/share/bash-completion/git
# Cool trick to show current git branch in the command prompt in gentoo colors.
export PS1='\[33[01;32m\]\u@\h\[33[01;34m\] \w$(__git_ps1 " (%s)") \$\[33[00m\] '

(Attention: wordpress removes for any reason my “\ 0 3 3” sequences (without space) so that you see only 33 instead.)
If you enter your working dir the prompt will look like this.

gergap@lt_gergap ~/work/helisim (master) $

If you are wondering what this “\[33…]” is for, this is just to set some nice colors for the prompt. You can remove that if you don’t like colors.

Advertisements

0 Responses to “GIT bash cheats”



  1. Leave a Comment

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s





%d bloggers like this: