Article View: gnu.bash.bug
Article #601Seeing control characters in aliases and functions
From: Brian Fox
Date: Fri, 15 Sep 1989 16:54
Date: Fri, 15 Sep 1989 16:54
47 lines
2390 bytes
2390 bytes
Date: Fri, 15 Sep 89 07:51:23 EDT
From: James J Dempsey <jjd@alexander.bbn.com>
>> From: Rich Salz <rsalz@BBN.COM>
>> Subject: Re: Seeing control characters in aliases and functions
>> To: bug-bash@prep.ai.mit.edu
>>
>> In <8909142124.AA25167@aurel.caltech.edu> bfox@aurel.caltech.edu suggests
>> I fix my "pwd" function to use "echo -e":
>> function pwd () {
>> echo -n -e "\033]lBASH@${host}(${TTY}):$PWD\033\010"
>> }
>> Hand smacks head, and voice goes "duh."
>>
>> >Thanks for the neat function!
>> No prob. Of course, it makes the most sense when used with this:
>> function cd() {
>> builtin cd $*;
>> pwd
>> }
>> and similar functions for pushd/popd.
I assume the esc seqence in your alias is to update the title bar in
your xterm window.
I have had something similar to this for a while, but I find that it
isn't enought to make aliases for cd, pushd and popd. In fact, I seem
to remember that tcsh had an automatic alias (similar to PROMPT_COMMAND)
which would automatically get executed whenever a directory was
changed (by cd, pushd, or popd or whatever). This still wasn't good
enough. Consider the case:
% ( cd foo/bar/baz; make )
Your cd alias will get executed, your xterm title will change to
reflect the new directory but it will never get set back to the
current directory when the subshell exits. I find that the only way
to have an alias keep the current directory up to date in the window
title is to use PROMPT_COMMAND. Since the alias you use in
PROMPT_COMMAND only uses builtins, it doesn't have that much overhead.
Huh? Upon seeing Rich's `pwd' function, I immediately called it xtitle,
and then set PROMPT_COMMAND=xtitle. Now everything works the way I want
it to. No?
Brian
Technical Details
Message-ID:
<8909151654.AA26774@aurel.caltech.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!AUREL.CALTECH.EDU!bfoxReferences:
<8909151157.AA01759@life.ai.mit.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!AUREL.CALTECH.EDU!bfox From: bfox@AUREL.CALTECH.EDU (Brian Fox) Newsgroups: gnu.bash.bug Subject: Seeing control characters in aliases and functions Message-ID: <8909151654.AA26774@aurel.caltech.edu> Date: 15 Sep 89 16:54:45 GMT References: <8909151157.AA01759@life.ai.mit.edu> Sender: daemon@tut.cis.ohio-state.edu Reply-To: bfox@aurel.caltech.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 47