On Tue, Dec 26, 2000, Adi Stav wrote about "Re: spaces in filenames":
> Speaking of, by the way, I wonder why almost everybody I've seen who
> digs smart xterm titles uses the cd trick instead of something like:
> 
> PS1_SIMPLE="\h: \w "
> PS1="\[\033]0;${PS1_SIMPLE}\007\]${PS1_SIMPLE}"

Maybe because your solution (at first glance - I didn't try it) changes the
title on every prompt? This is a waste of bandwidth (though you won't notice
it unless you have a slow line - e.g., log in to a computer abroad, or
use a slow modem, or worse - a slow X connection). In some window managers it
may also cause the title to flash on every prompt (though if it does, it's a
bug that needs to be corrected in the window manager).

Anyway, your solution isn't bad - it's just that there's a more efficient
solution: to only change the title when it needs changing, i.e., when the
current directory has changed.

By the way, in zsh there's an even more elegant solution (if anybody got
the impression that I'm an avid zsh advocate, they are right): zsh's
standard 'cd' builtin runs a user-define function 'chpwd' after changing
the directory, if such a function exists. So all you need to do is to
add something like the following to your .zshrc (no need for 'cd' functions
or aliases):

chpwd(){
        case "$TERM" in
        xterm|screen)   print -n '\033]2;'"$LOGNAME@$SYS":$PWD'\007';;
        esac
}
chpwd   # run this once in the .zshrc to show the initial current directory



-- 
Nadav Har'El                        |     Wednesday, Dec 27 2000, 1 Tevet 5761
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |I don't live on the edge, but sometimes
http://nadav.harel.org.il           |I go there to visit.

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to