[TriLUG] Shell prompt tweaks

Kevin Sonney alchemist at darkcanvas.com
Thu May 29 21:48:13 EDT 2003


On Thu, May 29, 2003 at 10:31:42PM -0400, Justin Johnson spoke thusly:
> I'm looking to tweak my shell prompt so that it includes the full path
> to the current directory, i.e instead of "[justin at mahi justin]$" I would
> have "[justin at mahi /home/justin]$"

Mine does color and also sets the title on some xterms. here's the
relevant parts :

# .bashrc

# echo "setting up terminal" 
export TERMIMON=`tty|cut -d/ -f3`
export COLOR1="\[\033[1;36m\]"
export COLOR2="\[\033[0;37m\]"
export COLOR3="\[\033[1;37m\]"
export COLOR4="\[\033[1;37m\]"

HOSTNAME=`hostname -s`

# echo "Setting up prompts for $HOSTNAME"

if [ "$BASH" ]; then
  case $OSTYPE in
  linux-gnu)
    PS1="$COLOR2[$COLOR1\u$COLOR3@$COLOR1\h$COLOR2]$COLOR2($COLOR3\w$COLOR2)$COLOR3>$COLOR4 "
    if [ "$TERM" = "dumb" ]; then
       PS1='[\u@\h](\w)\$ '
    fi
    ;; 
  *)
    PS1='[\u@\h](\w)\$ '
    ;;
  esac;
fi

if [ "$TERM" = "xterm" ]; then
    PROMPT_COMMAND='WD=${PWD#$HOME}; if [ "$WD" != "$PWD" ]; then WD="~$WD"; fi; echo -ne "\e]0;$LOGNAME@$HOSTNAME:${WD}\007"'
fi

if [ "$TERM" = "Eterm" ]; then
    PROMPT_COMMAND='WD=${PWD#$HOME}; if [ "$WD" != "$PWD" ]; then WD="~$WD"; fi; echo -ne "\e]0;$LOGNAME@$HOSTNAME:${WD}\007"'
fi
export PS1 

# echo "Done!"

> I looked through the Red Hat docs and didn't see any pointers, as well
> as Googling on <RedHat prompt customize>.

You probably want to look for "bash prompt customization" or
similar, since this is a bash thing and not Red Hat Linux specific.

-- 
----------------------------------
--         Kevin Sonney         --
--  ICQ: 4855069  AIM: ksonney  --
----------------------------------
320C 0336 3BC4 13EC 4AEC  6AF2 525F CED7 7BB6 12C9
 Reality is that which, when you stop believing in it, doesn't go away
 -- Philip K. Dick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://www.trilug.org/pipermail/trilug/attachments/20030529/a4e05a93/attachment.pgp>


More information about the TriLUG mailing list