# $Id$ # VERSION 1.2 (2001-10-31) # # coloured prompts for bash # # prompt is user@host:/dir$ where host is highlighted in green if the last # command exited 0 or in red (followed by the error code) otherwise # # to use, add a call to __ps1 in your .bash_profile export PROMPT_OK_COLOUR=32 export PROMPT_FAILED_COLOUR=31 function __ps1() { export PS1='\u@\[\033[1;$(__ps1_col $?)m\]\h\[\033[0m\]$(__ps1_ret $?):\w\$ ' return 0 } function __ps1_col() { [ $1 -gt 0 ] && echo -n "$PROMPT_FAILED_COLOUR" || echo -n "$PROMPT_OK_COLOUR" return $1 } function __ps1_ret() { [ $1 -gt 0 ] && echo -n " ($1)" return 0 }