When providing command examples for others I change my ksh prompt from my more informative prompt to the default ksh dollar sign.
Actually this all started years back when I first worked at Prime
Computer Solution Centre in Hayes. It was a habit I learned quickly
as a well respected colleague, David Brown (Thanks for all your help
David, much appreciated… where are you now?) would not give me
advice with a long Primos CPL prompt that caused my command line to
wrap and foul up ‘como’ files (that’s script(1) in UNIX speak).
To change the prompt promptly to and from the default I have two aliases
set up, spromt and lprompt (at Prime I named them
dave and stace respectfully). These work like this:
enoexec(5.11-64)$ sprompt $ alias sprompt sprompt=PS1='"$OPS1";export PS1' $ alias lprompt lprompt=PS1='"$LPS1"; export PS1' $ lprompt enoexec(5.11-64)$
The values of environment variable OPS1 and LPS1 are set in a
script which is ‘sourced’ by my .profile, the script includes:
## Set up prompt; use sprompt or lprompt alias to exchange prompts... [[ -x /bin/isainfo ]] && bits="-$(/bin/isainfo -b)" || bits="" [[ $(/bin/uname -p) == "i386" ]] && bits="${bits}i" case $TERM in "sun-cmd") # For some reason 'tput' fails to work for sun-cmd! bold='33[K7m' norm='33][m' break;; "emacs") # tput complains about emacs bold="" norm="" break;; *) bold=`tput bold` norm=`tput sgr0` ;; esac [[ $(/bin/id) == *root* ]] && OPS1='# ' || OPS1='$ ' export OPS1 ## if parent used /bin/script then use simple prompt. if [[ $(/bin/ps -p$PPID) == *script* ]]; then export PS1=$OPS1 else LPS1="$bold$UNAME($(/bin/uname -r)${bits})$norm$OPS1" export PS1="$LPS1" fi unset bits bold norm
Stace
Tag: ksh