Author Topic: Problem configuring "less" via exporting the LESS environment variable  (Read 517 times)

Offline coldoak

  • New Friend
  • *
  • Posts: 5
Hi there,

beforehand: I'm posting this in the LXDE forum, because I don't have the following problem on my other computer, which is running the KDE version of PCLOS.

OK, but now to my problem:

I need to customize the default configuration of "less" via changing the LESS environment variable.
(PERLDOC doesn't show escaped characters right when called with default configured less, but with the customized options it will).

So it goes, if I do it manually every time when I open a new terminal:

Code: [Select]
[thomas@06022012 ~]$ echo $LESS
-MM
[thomas@06022012 ~]$ export LESS=mqeisz-2XR
[thomas@06022012 ~]$ echo $LESS
mqeisz-2XR
[thomas@06022012 ~]$

When I add the line "export LESS=mqeisz-2XR" to the .bash_profile and .bashrc lying in my home directory, every new terminal still shows "-MM" when echoing the LESS variable.

On the KDE version that was the way to go - so it must be some LXDE specific, I assume.

Thanks for reading  :)

Thomas

Offline djohnston

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6227
  • I don't do Windows

On the KDE version that was the way to go - so it must be some LXDE specific, I assume.


Nope. Just added:

export LESS=mqeisz-2XR

as last line of my ~/.bashrc. Result?

echo $LESS
mqeisz-2XR

Make sure it's the last line you entered in ~/.bashrc, and that you end the line with a carriage return. Yes, I'm using LXDE desktop.
Bare metal                           VBox
AMD Athlon 7750 Dual-Core    Single core
4GiB RAM                              1GiB RAM
nVidia GeForce FX 5200          64MB video
LXDE 32bit                            KDE 64bit

Registered Linux User #416378

Offline coldoak

  • New Friend
  • *
  • Posts: 5
Mmmmhh, yes - you're right   ;D

The addition of the "export" command on the last line did the trick.
I always wrote it right under the line which says "# User specific aliases and functions".

Do you perhaps know, why this makes a difference???

Oh my, I sat hours on this, searching the web and even trying to find out how to make the change system wide by editing some obscure files in /etc and deeper, before posting here...

And then, in the end, it's so easy - thanks for this, djohnston  :D

Offline djohnston

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6227
  • I don't do Windows

Do you perhaps know, why this makes a difference???


Not entirely sure, unless I spent more time researching this. Here is my suspicion. In the following ~/.bashrc section:

    if [ -z "$loginsh" ]; then # We're not a login shell
   # Not all scripts in profile.d are compatible with other shells
   # TODO: make the scripts compatible or check the running shell by
   # themselves.
   if [ -n "${BASH_VERSION}${KSH_VERSION}${ZSH_VERSION}" ]; then
            for i in /etc/profile.d/*.sh; do
           if [ -r $i ]; then
               . $i
           fi
       done
       unset i
   fi
    fi



all the shell scripts in /etc/profile.d directory are run. One of the shell scripts is /etc/profile.d/20less.sh. If we look for an export command,

cat /usr/bin/lesspipe.sh | grep export
#      LESSOPEN="|lesspipe.sh %s"; export LESSOPEN   (sh like shells)
    echo "export LESSOPEN"


we see that the LESSOPEN environment variable is set. I'm pretty sure it overrides earlier $LESS variables. You may want to research it yourself.
Bare metal                           VBox
AMD Athlon 7750 Dual-Core    Single core
4GiB RAM                              1GiB RAM
nVidia GeForce FX 5200          64MB video
LXDE 32bit                            KDE 64bit

Registered Linux User #416378

Offline coldoak

  • New Friend
  • *
  • Posts: 5
Thank you for this detailed explanation.

It looks interesting enough, to take another set of ours time to delve deeper into this.
I don't like it, when my expectation and any given explanation are not coherent...  ;)

If I'll find out anything of interest, I'm gonna post again on this subject.

If not, I'm still thankful for your help... :D

Thomas

Offline menotu

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 15279
  • ┌∩┐(◕_◕)┌∩┐
Oh my, I sat hours on this, searching the web and even trying to find out how to make the change system wide by editing some obscure files in /etc and deeper, before posting here...

The PCLinuxOS Forum (and the OS's) is a MORE ENVIRONMENT!!   ;D ;D
PCLinuxOS 32bit KDE 4.10.1; kernel-3.4.11-pclos1.bfs & 64bit 3.2.18bfs; NVidia GeForce 8400GS 1GB 310.19 driver

Sony Vaio SVE1513A4ESI Laptop, Intel Core i5, 2.6GHz, 6GB RAM, 750GB, 15.6" Intel HD Graphics 4000