You realize, of course, that everytime you press return, this will
invoke perl in all it's 5MB glory?
Robert G. Werner
[EMAIL PROTECTED]
It's not my fault ... I didn't vote for him.
I'm frequently appalled by the low regard you Earthmen have for life.
-- Spock, "The Galileo Seven", stardate 2822.3
On Fri, 7 Sep 2001, 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.
>
> --
> Craig S. Cottingham
> [EMAIL PROTECTED]
> PGP key available from:
> <http://pgp.ai.mit.edu:11371/pks/lookup?op=get&search=0xA2FFBE41>
> ID=0xA2FFBE41, fingerprint=6AA8 2E28 2404 8A95 B8FC 7EFC 136F
> 0CEF A2FF BE41
>