I found a good customization to my .bashrc for my prompt to show extra information and provide color highlighting. Here’s what I have:
# ----- Define a few Colors
BLACK='\e[0;30m'
BLUE='\e[0;34m'
GREEN='\e[0;32m'
CYAN='\e[0;36m'
RED='\e[0;31m'
PURPLE='\e[0;35m'
BROWN='\e[0;33m'
LIGHTGRAY='\e[0;37m'
DARKGRAY='\e[1;30m'
LIGHTBLUE='\e[1;34m'
LIGHTGREEN='\e[1;32m'
LIGHTCYAN='\e[1;36m'
LIGHTRED='\e[1;31m'
LIGHTPURPLE='\e[1;35m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
function __setprompt {
local SSH_IP=`echo $SSH_CLIENT | awk '{ print $1 }'`
local SSH2_IP=`echo $SSH2_CLIENT | awk '{ print $1 }'`
if [ $SSH2_IP ] || [ $SSH_IP ] ; then
local SSH_FLAG="@\h"
fi
PS1="$CYAN[\u$SSH_FLAG:$BROWN\w$CYAN]\\$ $NOCOLOR"
PS2="$CYAN>$NOCOLOR "
PS4='$CYAN+$NOCOLOR '
}
__setprompt
The issue I’m running into is that it doesn’t handle wrapping text correctly (see below screenshot). Can anyone offer any advice on what the problem might be? It looks like it doesn’t adjust at all what is typed in by the user.

what’s the value of
CYANBROWNNOCOLORvars ?You most problably forgot to wrap them in
\[and\],to mark them as non-printing characters.
if your
CYANisyou need to wrap it in
\[and\], likeotherwise, wrap the vars themselves in the prompt variables, like
see the comments here:
also, have a look at
PROMPT_COMMANDvariable,and also note that by convension capital variable names are kept to be used by the environment