I’m trying to get my iTerm prompt set up the same way as Paul Irish
So far I have the following in ~/.profile:
# Add git branch name to prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/*\(.*\)/ on \1/'
}
PS1='\n\[\033[0:35m\]\u\[\033[0;32m\]\w\[033[0m\]$(parse_git_branch)\n\$\[\033[0m\] '
I don’t know how to make just the branch appear in a different colour and not the preceding “on”
As well as this there are other features such as:
- Displaying an “o” at the prompt when not in a git branch
- Displaying a “±” when in a branch
- Displaying the date at the end of the line
Any help would be appreciated
I’ve just written a post about how to do all this. I’ve covered all the basics but had to guess a couple of things, e.g. how Paul uses the symbols etc. If you want to read it, check out http://digitalformula.net/articles/pimp-my-prompt-like-paul-irish.
There’s also an article on digitalformula.net that shows a couple of other prompt examples – see http://digitalformula.net/articles/a-couple-more-bash-prompt-examples.
EDITED:
The code part is as follows: