From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22536 invoked from network); 1 Jun 2002 21:30:20 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 1 Jun 2002 21:30:20 -0000 Received: (qmail 956 invoked by alias); 1 Jun 2002 21:30:04 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5026 Received: (qmail 939 invoked from network); 1 Jun 2002 21:30:02 -0000 From: "Bart Schaefer" Message-Id: <1020601212932.ZM9170@candle.brasslantern.com> Date: Sat, 1 Jun 2002 21:29:32 +0000 In-Reply-To: <20020531222348.A4491@radiomaranon.org.pe> Comments: In reply to Andy Spiegl "Re: My zshrc; any sugestions welcome" (May 31, 10:23pm) References: <20020325175935.A1729@nymos.home.hr> <20020326103835.A175@nymos.home.hr> <1020326151112.ZM32099@candle.brasslantern.com> <20020326174631.A831@nymos.home.hr> <1020326171031.ZM32266@candle.brasslantern.com> <20020401123118.A381@nymos.home.hr> <20020531222348.A4491@radiomaranon.org.pe> X-Mailer: Z-Mail (5.0.0 30July97) To: Andy Spiegl , zsh-users Subject: Re: My zshrc; any sugestions welcome MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On May 31, 10:23pm, Andy Spiegl wrote: } Subject: Re: My zshrc; any sugestions welcome } } Hi Marijan, } } > > preexec () { } > > print -Pn "\033]0;%n@%m ${${(@)${(z)1}:#*[[:punct:]]*}%% *} %~\007" } > > } } > } > I just now noticed that it's not working for 'two_or_more' word job ex. } } Right, that's bothering me right now, too. The function as quoted is designed to show only the command name. The ${...%% *} in the expression above strips off everything after the first word. Inside that, ${(@)...:#*[[:punct:]]*} removes all words that contain punctuation (which would include file names with dots in them). The intent was that, if for example you give a command such as CVS_RSH=ssh cvs update or ( scp some list of files remote:directory ) the variable assignments and parentheses will be discarded before figuring out what command name to display. } > With '$1' it works perfectly? (shows complete line). } > Why is $1 bad? } First I didn't understand it either, then I stumbled over more complicated } command lines with quotes and stuff in it. The real danger is that the command line will contain a control character or the like which the terminal interprets, or (as in your next example) that it will contain a backslash sequence like \n which `print' will turn into something unwanted. A secondary problem is that the command line may be much longer than you really want to put into your title bar. What if the command is a multi- line `for' or `while' loop? } For example, try: } } echo hi | perl -ne 'print "oops\n"' } } This should just print: } oops } but with <$1> in preexec it prints: } } "'>" pts/17 ~oops This happens because the \n in "oops\n" gets turned into a real newline by `print -nP', and the newline terminates the title bar string the same way that the \007 would have. A similar thing would happen if the command contained an actual newline, such as a multi-line loop body would. } I'd really get it to work the way you tried, but I can't figure it out. :-( } Any suggestions anyone? If you have zsh 4.0.x, you might try: preexec () { print -Pn "\033]0;%n@%m ${(Vq)2} %~\007" } The doc for preexec says "the second argument is a single-line, size- limited version of the command (with things like function bodies elided)". The (Vq) means to render any control characters in a visible format and to quote any special characters in the string with backslashes. There isn't any simple way to get the equivalent in 3.x. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net