On Fri, 07 Sep 2001 at 01:01:44 -0500, Craig S. Cottingham wrote:
> > /Users/me/Documents/LearnC/FirstSteps
> > then I'd like
> > .../LearnC/FirstSteps
> > to display in the title bar (or on the prompt).
> > 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.
Well, this requires a zero-length perl program.
Zsh supports this feature directly, and it's part of my standard setup,
which is, on xterms:
prompt='%{ESC];%n@%m %~^GESC]1;%m %.^G%}%2. %# '
This writes the full directory name (with '~' contraction) into the
window title, and abbreviated ones into the command line and icon box (2
and 1 components respectively). Do I have to say that you replace ESC
and ^G with the control characters?
Sorry, no perl and not much fun. Just a sales pitch for zsh. Zsh has
been described as having every feature you could possibly want in a
shell, except for small size. It's still smaller than bash, though :-)
Ian
(Working kit: perl, vim, zsh. Take it everywhere)