[NTLUG:Discuss] Re: Bash can put the current command into your xterm title

Val W. Harris vwharris at airmail.net
Tue Aug 20 23:08:59 CDT 2002


Lance Simmons wrote:

> 
> Were you able to do it with bash before 2.05b?
> 

I've been using the following alias and bash scripts since
RedHat 3 or 4.  I put the lines in my .bashrc file.

#---------------------------------------------------------
alias cd=_cd

#
#--------------------------------
#  Set up some useful functions.
#--------------------------------
_cd(){
   HOST=`hostname | awk -F'.' '{ print $1 }'`
   \cd ${1+"$@"}
   if [ "${TERM}" = xterm ]
   then
     xtitle "${USER}@${HOST} [${PWD}]";
   fi
}

xtitle() {
                      echo -e "<esc>]0; ${1+"$@"}<Ctrl-G>\c"
         }
#---------------------------------------------------------

The <esc> is a single escape character, and the <Ctrl-G> is
a control-G character.  Remove the angle brackets when you
insert the character.

HTH,

Val
-- 
Val W. Harris              vwharris at airmail.net

I'd rather be a failure at something I enjoy
than be a success at something I hate.
- George Burns





More information about the Discuss mailing list