🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #596

Re: Seeing control characters in aliases and functions

#596
From: James J Dempsey
Date: Fri, 15 Sep 1989 11:51
39 lines
2000 bytes
>> 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.

		--Jim--
Technical Details
Message-ID: <8909151157.AA01759@life.ai.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ALEXANDER.BBN.COM!jjd
References: <1953@prune.bbn.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ALEXANDER.BBN.COM!jjd
From: jjd@ALEXANDER.BBN.COM (James J Dempsey)
Newsgroups: gnu.bash.bug
Subject: Re: Seeing control characters in aliases and functions
Message-ID: <8909151157.AA01759@life.ai.mit.edu>
Date: 15 Sep 89 11:51:23 GMT
References: <1953@prune.bbn.com>
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 39