To make your bash prompt super spiffy (and equally useful), add this to ~/.bashrc:
#Adding git branch to command promptgitStatus() { git diff --quiet 2> /dev/null || echo ' *' ; }
gitBranch() { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ > \1$(gitStatus)/" ; }
Then, somewhere in your $PS1, put \$(gitBranch). Here's an example; try it:
export PS1="[\u@\h$ \w\$(gitBranch)]\$ "
When you're in a git directory, you'll notice the branch name on the prompt. If the branch has been modified, an asterisk will appear next to the name. Here is an example :
My command prompt looks like this -
cdump@cdump-linux : /workspace/android/platform > cros-wm *$
indicating I am on cros-wm branch and there are modified files.
Git-goodness!
Credit Serban Giuroiu
Credit Serban Giuroiu
Someone seems to have become a git goddess. I still remember our struggles with git. And yeah... "what a GEEK"
ReplyDeleteI kinda of mostly remember my branch - and an occasional git status or git branch doesn't hurt
ReplyDeleteUseful - when i start having a lot of branches.
I find git autocomplete commands more useful though :)
@Sastry, I have no choice and I am still afraid of git :P
ReplyDelete@rohit I agree autocomplete is useful.
I often switch workspace so branch-name on prompt becomes handy.
This blog is very inspiring to me. With pleasure I will recommend this blog to my friends.
ReplyDeleteI am very glad that I got to this site
ReplyDeleteerotic call out escorts
ReplyDeletevidmate
Read Latest 2020 Hindi, Punjabi Song Lyrics:
ReplyDeleteSocial Disdancing Lyrics in Hindi - Manj Musik, Manak-E
वक़्त Waqt Lyrics in Hindi - Oye Kunaal
डियर मामा Dear Mama Lyrics in Hindi - Sidhu Moose Wala
विहा नई करौना Viah Nai Karauna Lyrics in Hindi - Asees Kaur
भीगी भीगी Bheegi Bheegi Lyrics in Hindi – Neha Kakkar, Tony Kakkar
भूला ना तेरी बातें Bhula Na Teri Baatein Lyrics in Hindi - Stebin Ben
मंज़िल Manzil Lyrics in Hindi - Jatt Prabhjot | lyricswhispering
Canli
ReplyDelete