Home
subscribe

L'etat, c'est moi

Mere Complexities sells the consulting and development services of me, Paul Wilson.

Conferences

Organising Scotland on Rails
Speaker, RailsConf Europe '08

Archive

My command line prompt with Git

All the cool kids these days like to have the current Git branch as their command-line prompt. Call me old fashioned, but I like to know my current directory as well. As showing the full path can get ridiculous, I just want the directory name.

This is what I ended up with in my .profile:


export PS1=\
'$(echo $PWD| sed s/.*\\\///) \
$(git branch &>/dev/null; if [ $? -eq 0 ];\
 then echo "(\[\033[00m\]$(git branch | grep ^*|sed s/\*\ //)) ";\
 fi)\$\[\033[00m\] '

(The Git part was copied from the Internet somewhere – I forget where.).

This is what it looks like:

git prompt

All