News for hackers. Stuff that matters.
Re:Interesting Bash Prompts by davidw on Sunday September 06, 2009 @02:18AM (#807537)
I changed mine for the first time in years, to show me which git branch I'm in, to avoid doing the wrong thing in the wrong place.

    davidw@fortrock:~/workshop/langpop (master) $
Re:Interesting Bash Prompts by tlrobinson on Sunday September 06, 2009 @04:52AM (#807613)
+1 for the git branch.

Here's my bash prompt script. It shows the command number from this session (PS_NUM), the exit code of the last command (highlighted red if != 0), the pwd (in cyan), and the git branch (in magenta)

    OFF="\[\033[0m\]"
    RED="\[\033[0;31m\]"
    MAGENTA="\[\033[0;35m\]"
    CYAN="\[\033[0;36m\]"

    function promptcommand {
        STATUS=$?
    
        PS_NUM="[\#]"
        PS_STATUS="[$STATUS]"
        PS_PWD="${CYAN}\w${OFF}"
        PS_GITBRANCH="${MAGENTA}\$(__git_ps1)${OFF}"
        PS_PROMPT="\$"
    
        if [ $STATUS -ne "0" ]; then
            PS_PROMPT="${RED}${PS_PROMPT}${OFF}"
        fi
    
        PS1="${PS_NUM}${PS_STATUS} ${PS_PWD}${PS_GITBRANCH} ${PS_PROMPT} "
    }
    PROMPT_COMMAND=promptcommand
I probably could have eliminated the PROMPT_COMMAND thing like in the first example.
Re:Interesting Bash Prompts by forsaken on Sunday September 06, 2009 @02:03PM (#807994)
I use vcprompt, it works with all the major ones, and is written in C to be fast: http://vc.gerg.ca/hg/vcprompt/
Re:Interesting Bash Prompts by extension on Sunday September 06, 2009 @07:14PM (#808276)
Mine shows git branch and changed file status: http://code.extension.ws/post/181469611/git-prompt-rb

It's a Ruby script so not the fastest in theory, but I haven't noticed any delay using Ruby 1.9

Re:Interesting Bash Prompts by lvv on Tuesday September 08, 2009 @08:26AM (#810772)
There is faster version of this. In pure bash. And can do much more, including GIT, SVN and HG. Screen shots: http://volnitsky.com/project/git-prompt
Re:Interesting Bash Prompts by dan00 on Sunday September 06, 2009 @06:21AM (#807667)
If you like that, perhaps you will like these:

export GIT_PS1_SHOWDIRTYSTATE=1

export GIT_PS1_SHOWSTASHSTATE=1

export GIT_PS1_SHOWUNTRACKEDFILES=1

Re:Interesting Bash Prompts by dchest on Sunday September 06, 2009 @07:37AM (#807714)
Here's mine for Mercurial (shows branch and changeset number): http://gist.github.com/181764
Re:Interesting Bash Prompts by durin42 on Sunday September 06, 2009 @01:09PM (#807935)
Here's a version that automatically DTRT for git, hg, and svn (hg last in implementation so my home doesn't override other repositories): http://bitbucket.org/durin42/dotfiles/src/tip/.shell.d/50.vc...

Here's the code for the zsh prompt that uses it: http://bitbucket.org/durin42/dotfiles/src/tip/.shell.d/99.pr...