Re: [OT] git branches and command prompts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sorry, TB mangled the formatting.  Hopefully quoting helps. :-(

Jason wrote:

if you're like me, you play with a lot of open source code. A lot of it is now in git repositories. I frequently forget which branch I'm on in each project, particularly with Android/Cyanogen. Here's a hack I figured out that helps me out, place it in ~/.bashrc :

### begin ####
PROMPT_COMMAND="echo -n \${PWD};
   if git branch >/dev/null 2>&1; then
      echo -n \"(\$(git branch | grep ^* | cut -d ' ' -f 2-))\"
PS1="\n[\[\033[01;34m\]\u\[\033[00m\]@\h] $ "
### end ######

Here's the result:

[jason@phantom] $ cd src/foss/git.git
/home/jason/src/foss/git.git (master)
[jason@phantom] $ git checkout git_shell_dir_opt
Switched to branch 'git_shell_dir_opt'
/home/jason/src/foss/git.git (git_shell_dir_opt)
[jason@phantom] $

To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at

[Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

Add to Google Powered by Linux