Re: wrap long lines
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sunday, August 27 at 11:18 AM, quoth Gary Johnson:
>> How do I ..
>>
>> 1. access the contents of an environment variable in mutt
You can access any environment variable that is actually in the
environment by simply referring to it, beginning with a dollar sign.
>> 2. code a set statement that accesses a *nix env variable
>
> set wrapmargin=`echo $(( $COLUMNS - 80 ))`
>
>The expression in back-tics is given to the shell for evaluation.
>This is briefly mentioned in section 3.1 of the mutt manual, "Syntax
>of Initialization Files".
HEH. Your example is correct, but is hiding several details which may
lead to confusion later.
First, COLUMNS is not an environment variable by default, it's merely
a shell variable. What that means, for example, is that the following:
set wrapmargin=$COLUMNS
Will result in $wrapmargin being set to "". However, if you explicitly
export COLUMNS before running mutt, the above command will result in
$wrapmargin being set to the value of COLUMNS (e.g. 80). Obviously,
setting $wrapmargin to $COLUMNS is a bad idea, I'm just using it as an
example.
If you don't want to export COLUMNS, the following command will do the
"right" thing:
set wrapmargin=`echo $COLUMNS`
The reason for that is that the backticks spawn a shell! The shell
then defines all of it's own internal variables (like $BASH_VERSION)
that are not environment variables, and will recognize and substitute
the correct value for $COLUMNS when interpreting the command line.
Finally, we get to the command you recommended:
set wrapmargin=`echo $(( COLUMNS - 80 ))`
The last remaining detail of how that actually works is the $(( ))
syntax, which is a useful trick for making bash do basic arithmetic.
I know, I know, I'm being unnecessarily verbose, but might be useful
information for some lurkers on the list if nothing else.
~Kyle
- --
If you cannot change your mind, how can you be certain that you have
one?
-- Unknown
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!
iD8DBQFE8nc1BkIOoMqOI14RAu2yAKDhPsn8I8264ngamobcGkCKjHN86wCg9/9W
YfkbMZPeCVuNZsuIhjXJW98=
=iFse
-----END PGP SIGNATURE-----