On Thursday 06 September 2001 23:01, Craig S. Cottingham wrote:
>
> On the Mac OS X Unix mailing list (<X-
> [EMAIL PROTECTED]>), what started out as (IIRC) an
> innocent question about xterm escape sequences has become a
> hellish exercise in feeping creaturism. The line was crossed
>
> when someone asked:
> > E.g., if pwd is
> >
> > /Users/me/Documents/LearnC/FirstSteps
> >
> > then I'd like
> >
> > .../LearnC/FirstSteps
> >
> > to display in the title bar (or on the prompt).
>
> To which I replied:
> > Okay. Here's one way to do it, but I don't think you're going
> > to like it. :-)
> >
> > export PROMPT_COMMAND="perl -e
> > '@d=split/\//,qx(pwd);@d=(q(...),@d[\$#d-1..\$#d])if(@d>3);chomp@d;
> >print join(q(/),@d),q( )'"
> >
> > (That should all be one line, in case various mail handlers
> > happen to wrap it.) Figuring out how to turn that monstrosity
> > into an xterm sequence that sets the window title is left as an
> > exercise for the reader.... No, apparently I'm a glutton for
> > self-abuse, because here it is:
> >
> > export PROMPT_COMMAND="perl -e
> > '@d=split/\//,qx(pwd);@d=(q(...),@d[\$#d-1..\$#d])if(@d>3);chomp@d;
> >print qq(\033]0;).join(q(/),@d).qq(\007)'"
>
> Can anyone see a way the second script can be condensed? I don't
> fancy myself a golf expert (either in Perl or in real life), but
> I can't see any way to shorten it, save maybe for using regexes
> (which, frankly, I'm too tired at the moment to contemplate).
>
> You are allowed to assume that you're running bash on a
> Unix-like system, interacting via xterm or some other
> application that accepts xterm escape sequences.
export PROMPT_COMMAND="perl
-e'(\$_=qx[pwd])=~s!/.*?(/[^/]+/[^/]+)\$!...\$1!;chomp;print'"
John
--
John Wesley Krahn, CD
Vancouver, British Columbia, Canada