> "Price, Erik" <[EMAIL PROTECTED]> writes:
> 
> > > [please configure your email program to wrap lines at around 72
> > >  characters -- thanks...]
> > 
> > I can't seem to find the setting that lets you do that.
> > this is MS Outlook 2000. (I kinda hafta use it for work...)
> 
> IIRC, Derek Martin (and perhaps others) pointed these out once:
> 
>         http://www.lemis.com/email/fixing-outlook.html
>         http://www.slipstick.com/mail1/olinet.htm

Thanks for the resources.  Unfortunately it seems that the version
of Outlook used at my company has been configured to use Exchains,
which for some reason removes certain mail formatting features from
the application (according to those web pages).  I should look into
an alternative mail client, and only use Outlook for the scheduling
and workgroup features that my company uses, but Windows is not my
native environment so I don't know of any that are particularly
good...

> 
> > > Is
> > > 
> > >    PROMPT_COMMAND='pwd | perl -ne "chomp; print 
> substr(\$_, 0, 30);"'
> > > 
> > > what you want?
> > 
> > I'm sure that would work, but I was looking for an all-bash
> > solution (for pedagogical reasons).
> 
> Bah!  Well, here's a non-Perl solution.
> 
>   PROMPT_COMMAND='expr `pwd` : 
> "\(..............................\)" \| `pwd`'
> 
> I leave as an excercise to the reader the task of removing the
> (probably unwanted) newline that this generates.

That could be done by echoing out this value with the "-n" flag,
but let me see if I can explain better the script that I already
have.  It works beautifully, that is, it generates the appropriate
results -- the value of $PWD truncated to 30 characters from the
left.

#!/usr/local/bin/bash

# fixedprompt.sh
# 20021107 by Erik Price
# stolen from the Bash Prompt HOWTO
# generate an informative prompt, without occupying
# the whole line (truncated-left PWD)

# How many characters of the $PWD should be kept
pwdmaxlen=30

# indicator that there has been pathname truncation
trunc_symbol="..."
if [ ${#PWD} -gt $pwdmaxlen ]
then
        pwdoffset=$(( ${#PWD} - $pwdmaxlen ))
        newPWD="${trunc_symbol}${PWD:$pwdoffset:$pwdmaxlen}"
else
        newPWD=${PWD}
fi
# EOF

Now, the above simple script does exactly what it's supposed to
-- it reads the contents of the $PWD environment variable,
tests to see if it is greater than 30 characters long, and if so
it truncates it to the rightmost 30 characters and prepends an
ellipsis.  This value is stored in the $newPWD environment variable.
No problems.

Where I'm running into trouble is getting this value to
be echoed in my prompt, which is set in my .bashrc to this:

PS1="[\u@\h:${newPWD}]\$ "

A feature of bash that I was not previously aware of is that you
can place a value in the environment variable $PROMPT_COMMAND
and this will be executed every time a new prompt is generated.
So, I had this shell script in the $PROMPT_COMMAND variable in
my .bashrc file, like so:

PROMPT_COMMAND='/d00/users/prm/bin/fixedprompt.sh'

Now, thanks to the helpful folks on this list, I've realized that
executing this shell script whenever a prompt was generated was
having no effect because my shell session was not inheriting the
$newPWD variable.  After changing the value of PROMPT_COMMAND from
executing the shell script to *sourcing* the shell script, like
this:

PROMPT_COMMAND='. /d2/users/prm/bin/fixedprompt.sh'

... and then re-sourcing .bashrc to recognize the changes,
I get the desired effect -- $newPWD is echoed in my prompt and
it looks like this:

[prm@web-dev:/d2/users/prm]$

Now, coming to the main point of this whole email -- there is only
one problem:

The value of $newPWD appears only to be getting set when I
source ".bashrc", not every time a prompt is generated the way
that I hoped.  Which means that if I change directories, the same
old directory appears in $newPWD.  What I had hoped was that every
time a new prompt is generated, the value of $newPWD would be
generated from scratch (in other words, if I change directories
the change would be reflected in the new prompt).

Does anyone know how I can "protect" the value of PROMPT_COMMAND
so that it is not executed when .bashrc is sourced, but rather
when a new prompt is generated?  I've used single quotes, so I would
have thought that would do the trick -- it's not.

Any suggestions?


Erik

PS: is it possible to install "less" on this Solaris box without
root access? It's a company server, and I'm not an admin.  I'm
addicted to "less" for reading text files, but it doesn't seem to
be on this machine.  However, I did find something called
/opt/GCC281/bin/gcc so it seems I have access to a compiler....
_______________________________________________
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss

Reply via email to