X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=.profile.d%2Fps1.bashrc;fp=.profile.d%2Fps1.bashrc;h=cf6f1e69a4a1edeb8bcfe947824294286fa2443d;hb=41bfbf58f59c0def4ee9126a57e1bb07ba35a3f2;hp=852c73652c99a42feca2102e2279fff362e22b15;hpb=3355282d8c651fa4e8cf4c819095e47b9fb4bfeb;p=profile.git diff --git a/.profile.d/ps1.bashrc b/.profile.d/ps1.bashrc index 852c736..cf6f1e6 100644 --- a/.profile.d/ps1.bashrc +++ b/.profile.d/ps1.bashrc @@ -73,12 +73,20 @@ function __ps1() { # Default __ps1_user to 1. [ -z "$__ps1_user" ] && __ps1_user=1 - export PS1='$(__ps1_user $? \u@)\[\033[$(__ps1_col $? 2>/dev/null)m\]$(__ps1_user $? \h)\[\033[${GIT_COLOUR}m\]$(__ps1_git $? 2>/dev/null)\[\033[0m\]\[\033[${P4_COLOUR}m\]$(__ps1_p4 $? 2>/dev/null)\[\033[0m\]\[\033[${SVN_COLOUR}m\]$(__ps1_svn $? 2>/dev/null)\[\033[0m\]$(__ps1_ret $? 2>/dev/null):\w\$ ' + export PS1='$(__ps1_user $? \u@)\[\033[$(__ps1_col $? 2>/dev/null)m\]$(__ps1_user $? \h)\[\033[$(__ps1_colour_escape $GIT_COLOUR)m\]$(__ps1_git $? 2>/dev/null)\[\033[0m\]\[\033[$(__ps1_colour_escape $P4_COLOUR)m\]$(__ps1_p4 $? 2>/dev/null)\[\033[0m\]\[\033[$(__ps1_colour_escape $SVN_COLOUR)m\]$(__ps1_svn $? 2>/dev/null)\[\033[0m\]$(__ps1_ret $? 2>/dev/null):\w\$ ' return 0 } +# iTerm doesn't like it if you set bold and colour at the same time. +function __ps1_colour_escape() { + local bold="${1%%;*}" + local colour="${1#*;}" + + echo -en "${bold}m\033[$colour" +} + function __ps1_col() { - [ $1 -gt 0 ] && echo -n "$PROMPT_FAILED_COLOUR" || echo -n "$PROMPT_OK_COLOUR" + [ $1 -gt 0 ] && __ps1_colour_escape "$PROMPT_FAILED_COLOUR" || __ps1_colour_escape "$PROMPT_OK_COLOUR" return $1 }