rsalz@bbn.com (Rich Salz) (09/14/89)
Given these functions: TTY=`tty | sed -e s:/dev/ttyp::` host=`hostname | tr a-z A-Z | sed -e s/.BBN.COM//` function pwd() { # This has two ESCAPEs and one BACKSPACE in it. echo -n "^[]lBASH@${host}(${TTY}):$PWD^[\^H" } function cd() { builtin cd $*; pwd; } When I say "type pwd" my window banner gets all messed up. I know that being able to take your output as input is a good thing, but having to put "|cat -v" on the end all the time is a pain. Also, while I'm here: function bxmf() { make -k "$@" >foo 2>&1 & # It doesn't seem quite right that this next line is really needed... : ; } -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net. Use a domain-based address or give alternate paths, or you may lose out.
bfox@AUREL.CALTECH.EDU (Brian Fox) (09/15/89)
Date: 14 Sep 89 16:25:22 GMT From: rsalz@bbn.com (Rich Salz) Organization: BBN Systems and Technologies Corporation Sender: bug-bash-request@prep.ai.mit.edu Given these functions: TTY=`tty | sed -e s:/dev/ttyp::` host=`hostname | tr a-z A-Z | sed -e s/.BBN.COM//` function pwd() { # This has two ESCAPEs and one BACKSPACE in it. echo -n "^[]lBASH@${host}(${TTY}):$PWD^[\^H" } function cd() { builtin cd $*; pwd; } When I say "type pwd" my window banner gets all messed up. That's because you didn't use the -e flag on the echo command which would allow you to type in those escapes in ASCII representation: function pwd () { echo -n -e "\033]lBASH@${host}(${TTY}):$PWD\033\010" } Thanks for the neat function! Also, while I'm here: function bxmf() { make -k "$@" >foo 2>&1 & # It doesn't seem quite right that this next line is really needed... : ; } It isn't. You have mentioned this a couple of times. In 1.03, you don't even need to end the list with a terminator, but even in prior versions the newline character (or ampersand) is enough. function bxmf () { make -k "$@" >foo 2>&1 & } Brian Fox
rsalz@bbn.com (Rich Salz) (09/15/89)
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 re-complained about > function bxmf() { > make -k "$@" >foo 2>&1 & > # why is the next line necessary? > : ; > } Brian pointed out that it isn't in 1.03.... hand smacks the head again, voice goes "try it before posting." /r$ -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net. Use a domain-based address or give alternate paths, or you may lose out.
nickson@comp.vuw.ac.nz (Ray Nickson) (09/15/89)
From: rsalz@bbn.COM Date: 14 Sep 89 16:25:22 GMT Given these functions: TTY=`tty | sed -e s:/dev/ttyp::` host=`hostname | tr a-z A-Z | sed -e s/.BBN.COM//` function pwd() { # This has two ESCAPEs and one BACKSPACE in it. echo -n "^[]lBASH@${host}(${TTY}):$PWD^[\^H" } function cd() { builtin cd $*; pwd; } When I say "type pwd" my window banner gets all messed up. I know that being able to take your output as input is a good thing, but having to put "|cat -v" on the end all the time is a pain. I use xsettitle () { echo -n -e "\033]2 $1\007"; } xseticon () { echo -n -e "\033]1 $1\007"; } XTITLE="$XPROG" xseticon "$XTITLE" xsettitle "$XTITLE : $PWD" cd () { builtin cd $@; xsettitle "$XTITLE : $PWD"; } pushd () { builtin pushd $@; xsettitle "$XTITLE : $PWD"; } popd () { builtin popd $@; xsettitle "$XTITLE : $PWD"; } - no control chars needed! (do help echo). Also, while I'm here: function bxmf() { make -k "$@" >foo 2>&1 & # It doesn't seem quite right that this next line is really needed... : ; } Why _is_ it needed? The function seems to work fine for me (1.02 or 1.03) without it. BTW, Will functions ever have real argument lists?: xsettitle (t) { echo -n -e "\033]2 $t\007"; } BTW again: did the 1.03 patches Brian mentioned: I'm sorry that this bug appeared in 1.03. I will be posting patches for this and a few other fixed bugs on Friday, Sep 8. ever go out? We lost touch with the world for a few days, and I'd hate to have missed them. -rgn -- Ray Nickson, Dept. Comp. Sci., Victoria University of Wellington, New Zealand. nickson@comp.vuw.ac.nz ...!uunet!vuwcomp!nickson + 64 4 721000x8593
jjd@ALEXANDER.BBN.COM (James J Dempsey) (09/15/89)
>> 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--
bfox@AUREL.CALTECH.EDU (Brian Fox) (09/15/89)
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
chet@kiwi.CWRU.EDU (Chet Ramey) (09/16/89)
In article <8909142231.AA08032@comp.vuw.ac.nz> nickson@comp.vuw.ac.nz (Ray Nickson) writes: >BTW, Will functions ever have real argument lists?: >xsettitle (t) { echo -n -e "\033]2 $t\007"; } Functions already have "real argument lists". The only problem is that the arguments are always named "$1", "$2", and so on. ;-) Chet Ramey Chet Ramey "We are preparing to think about contemplating Network Services Group, CWRU preliminary work on plans to develop a chet@cwjcc.INS.CWRU.Edu schedule for producing the 10th Edition of the Unix Programmers Manual." -- Andrew Hume