From 4ba88ec0b2b95ca52534ecfdfa70bb72180cc663 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Thu, 2 Mar 2006 10:45:04 +0000 Subject: [PATCH] Prevent bash complaining after setting PS1 and su-ing to someone else. git-svn-id: https://svn.cambridge.iain.cx/profile/trunk@25 6be0d1a5-5cfe-0310-89b6-964be062b18b --- .profile.d/ps1.bashrc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.profile.d/ps1.bashrc b/.profile.d/ps1.bashrc index bb05253..f3907ea 100644 --- a/.profile.d/ps1.bashrc +++ b/.profile.d/ps1.bashrc @@ -1,21 +1,27 @@ # $Id$ -# VERSION 1.3 (2005-08-15) # # 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. # +# 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. +# To use, add a call to __ps1 in your .bash_profile file. +# export PROMPT_OK_COLOUR=${PROMPT_OK_COLOUR:-32} export PROMPT_FAILED_COLOUR=${PROMPT_OK_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 } -- 2.20.1