X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=.profile.d%2Fps1.bashrc;h=29fa7046367a6cb62f7495f50d4ebdf85c77d063;hp=f5fcb6a4df81fcf80703f3cbdb54d8c715ee605b;hb=205d13a1682023654539a9816055c014bb4dccca;hpb=7ff1edff9e3b22a1fd1f7798a634538d7ed94c54 diff --git a/.profile.d/ps1.bashrc b/.profile.d/ps1.bashrc index f5fcb6a..29fa704 100644 --- a/.profile.d/ps1.bashrc +++ b/.profile.d/ps1.bashrc @@ -1,17 +1,27 @@ -# VERSION 1.2 (2001-10-31) +# $Id$ # -# coloured prompts for bash +# 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 +# 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. +# +# Colouring is performed by the __ps1_col() and __ps1_ret() functions. +# We redirect stderr to /dev/null when calling these functions to prevent +# bash complaining about not knowing them when you su to another user, +# retaining PS1 but not the function definitions. +# +# Override the PROMPT_OK_COLOUR and PROMPT_FAILED_COLOUR environment variables +# to set different colours. +# +# To use, add a call to __ps1 in your .bash_profile file. # -# to use, add a call to __ps1 in your .bash_profile -export PROMPT_OK_COLOUR=32 -export PROMPT_FAILED_COLOUR=31 +export PROMPT_OK_COLOUR=${PROMPT_OK_COLOUR:-32} +export PROMPT_FAILED_COLOUR=${PROMPT_FAILED_COLOUR:-31} function __ps1() { export PS1='\u@\[\033[1;$(__ps1_col $?)m\]\h\[\033[0m\]$(__ps1_ret $?):\w\$ ' + export PS1='\u@\[\033[1;$(__ps1_col $? 2>/dev/null)m\]\h\[\033[0m\]$(__ps1_ret $? 2>/dev/null):\w\$ ' return 0 }