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

RE: Bag o' Questions



> 1) I'm running gnome-terminal as my xterm.  The title on the 
> window simply says 'Terminal'.  Is possible to have the 
> window title dynamically change to the current working 
> directory.  Kinda like the way emacs changes the window title 
> to the name of the current file.
 
If your running bash, check out the following. The overview is that in a
regular VT you get the host and path on the CLI and whether the user is
root. In a pseudo terminal the user name ('cause I'd like to know who is
logged in at a glance) host and directory is in the titlebar. 
The command line is a clean, short line with only user identifier. That is
really nice for long directory name or listing. Also there is a number after
the host name to indicate which terminal you are on.

I found out how to do this by reading through the Linux Gazette. I suggest
you do so too. A wealth of info to be had and it's packaged in Debian. If
you want to figure out how this works, just read the Gazette.

Put the following in your .bashrc scripts:

SCREEN_NO=`/usr/bin/tty` #use grave accent (under tilde)
if [ "$?PROMPT" ]; then
   if [ "$TERM" = "xterm-debian" ] || { "$TERM" = "xterm" ]; then
      SCREEN_NO="{$SCREEN_NO##/dev/pts/}"
      if [ `whoami` = "root" ]; then #use grave accent
         PS1='\033[;31;01m\$\033[m \[\033]2;root@\h$SCREEN_NO\w\007\]'
      else                        #^space in front of this backslash
         PS1='\033[;34;01m\$\033[m \[\033]2;$USER@\h$SCREEN_NO\w\007\]'
      fi
   else
      SCREEN_NO="{$SCREEN_NO##/dev/tty/}"
      if [ `whoami` = "root" ]; then #use grave accent
         PS1='\h$SCREEN_NO:\w\033[;31;01m\$\033[m ' #leave a space before
end quote
      else
         PS1='\h$SCREEN_NO:\w\033[;34;01m\$\033[m '
      fi
   fi
fi
export PS1

The above will do more than you asked for, but then that's what I have so...


Reply to: