[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Changing xterm titles to something more usefull than 'xterm'



> Changing the title bar dynamically can be done with the PROMPT_COMMAND
> environment variable (in bash). In my bashrc I have:
> 
> function settitle
> {
> #  title="`whoami`@`hostname`:(`date +%k:%M:%S`):`pwd`"
>   title="`whoami`@`hostname`:(`date +%k:%M:%S`):`history 1`"
>   echo -n "^[]2;$title^G" > /dev/tty
> }
> 
> if [ $TERM = "xterm" ] || [ $TERM = "xterm-color" ]; then
>     PROMPT_COMMAND=settitle
>     PS1='\h:\u > '
> fi

that would work too, but I think its a bit too complicated, I use this now:
HBLK='[[1;30m'
HBLU='[[1;34m'
BLU='[[0;34m'
YEL='[[0;33m'
WHT='[[0;37m'
NORM='[[1;0m'

case "$TERM" in
  xterm)
    export
PS1='\[$HBLK\]\[$BLU\]\[$HBLU\]\u\[$HBLK\]@\[$HBLU\]\h\[$BLU\]\[$HBLK\]\[$NORM\]\[$YEL\][\[$WHT\]\w\[$YEL\]]\[$NORM\]\$
\[\033]0;\u@\h \w\007\]'
  ;;
  *)
    export
PS1='\[$HBLK\]\[$BLU\]\[$HBLU\]\u\[$HBLK\]@\[$HBLU\]\h\[$BLU\]\[$HBL
\]\[$NORM\]\[$YEL\][\[$WHT\]\w\[$YEL\]]\[$NORM\]\$ '
  ;;
esac

this one has a color prompt.. :)

> 
> The second one only lists the last command executed. Don't know how to
> list the current one.

ah, I don't see any way of doing it..

Attachment: pgp1g6VTVVBhT.pgp
Description: PGP signature


Reply to: