Pages

Tuesday, March 12, 2013

Informative bash prompt

I hop between machines a lot at home. I want to know their IP address easily in addition to history count, user, and (if available) git branch in my .basrg
export PS1='($IP) [\!]\[\033[00;32m\]\u\[\033[01m\]@\[\033[00;36m\]\h\[\033[01m\]:\[\033[00;35m\]\w\[\033[00m\]\[\033[01;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s`\[\033[00m\]\$ '
e.g