# Useful terminal character enhancements export HB=$(/usr/bin/tput dim) # dim text export HV=$(/usr/bin/tput smso) # 1/2 bright inverse export IV=$(/usr/bin/tput bold) # inverse export UL=$(/usr/bin/tput smul) # underline export BL=$(/usr/bin/tput blink) # blink export EE=$(/usr/bin/tput sgr0) # end all enhancements # Setup the prompt string $PS1 # Set these values adjust the PS1 prompt: # PS1HOST=true or false (default is true - show hostname) # PS1USER=true or false (default is true - show username) # PS1DIR=0 1 or 2 (default is 2 - show lowest 2 levels of PWD) # PROMPT=# or $ (default is $ for a stabdard user) PS1HOST=${PS1HOST:-/usr/bin/true} # default = true PS1USER=${PS1USER:-/usr/bin/true} # default = true PROMPT=${PROMPT:-$} # default = $ USER="" HN="" # Some terminals do not have 1/2 bright inverse so let's test this # capability and substitute underline rather than $HV if tput smso > /dev/null then HVUL=$HV else HVUL=$UL fi # Set the hostname and username fields (if false, no field) $PS1HOST && HN="$HVUL$(/usr/bin/hostname)" $PS1USER && USER="$HB $(/usr/bin/id -un)" # To change the active PWD at every prompt, we must set the # PS1 value here using apostrophes ' ' to force an evaluation # of the current $PWD content. # Note the use of $EE to end the enhancements before the shell # prompt. Many terminals will stay in a specific setting onto # additional lines. $EE turns off all the enhancements. PS1DIR=${PS1DIR:-2} case $PS1DIR in 1 ) export PS1='$HN$USER $IV${PWD##*/}$EE $PROMPT ' ;; 2 ) export PS1='$HN$USER $IV${PWD##${PWD%/*/*}/}$EE $PROMPT ' ;; * ) export PS1='$PROMPT ' ;; esac