The 'less' command and colors

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
jplt3
Posts: 118
Joined: Mon 08 Apr 2019, 20:40
Location: Planet Earth

The 'less' command and colors

#1 Post by jplt3 »

Hi all,

i wanted to have colors with the command less on the terminal but it does not work :

Code: Select all

In the help we have :
  -r  -R  ....  --raw-control-chars  --RAW-CONTROL-CHARS
                  Output "raw" control characters.
i test on bionicpup64 with lxterminal.
JpLt

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#2 Post by Semme »

>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<

User avatar
jplt3
Posts: 118
Joined: Mon 08 Apr 2019, 20:40
Location: Planet Earth

#3 Post by jplt3 »

Thanks Semme,

i already try this solution but all failed , so i use a lot vim then if i want d view a file , i open it with vim in read only mode , with an alias :

Code: Select all

alias read='vim -R'
In some linux distributions there "view" that does the same thing.
JpLt

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#4 Post by Semme »

This Ask Ubuntu method works on my end. Maybe here too.
>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#5 Post by tallboy »

Hi jplt3, which file did you modify? In my tahr64, there is a /root/.profile that seems to be of limited use, but there is an /etc/profile with this line included:

Code: Select all

[ -r /etc/profile.local ] && . /etc/profile.local
I made a /etc/profile.local file, and modifies my urxvt there.

Remember that the ls used in Puppy is the one from busybox, and it's options list looks like this, from the man page:

Code: Select all

ls
    ls [-1AaCxdLHRFplinsehrSXvctu] [-w WIDTH] [FILE]...

    List directory contents

            -1      One column output
            -a      Include entries which start with .
            -A      Like -a, but exclude . and ..
            -C      List by columns
            -x      List by lines
            -d      List directory entries instead of contents
            -L      Follow symlinks
            -H      Follow symlinks on command line
            -R      Recurse
            -p      Append / to dir entries
            -F      Append indicator (one of */=@|) to entries
            -l      Long listing format
            -i      List inode numbers
            -n      List numeric UIDs and GIDs instead of names
            -s      List allocated blocks
            -e      List full date and time
            -h      List sizes in human readable format (1K 243M 2G)
            -r      Sort in reverse order
            -S      Sort by size
            -X      Sort by extension
            -v      Sort by version
            -c      With -l: sort by ctime
            -t      With -l: sort by mtime
            -u      With -l: sort by atime
            -w N    Assume the terminal is N columns wide
            --color[={always,never,auto}]   Control coloring
True freedom is a live Puppy on a multisession CD/DVD.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#6 Post by musher0 »

Hi jplt3.

The problem is lxterminal. It has its merits, but it filters out some stuff.
It may not understand the ANSI color codes sent by less.

May I suggest: go back to using urxvt as the terminal app.
Change /usr/local/bin/defaultterminal to

Code: Select all

#!/bin/ash
# type lxterminal >/dev/null 2>&1 && exec lxterminal "$@"
exec urxvt "$@"
Secondly, does your Pup have the real less application or only the link to
busybox? (It should be in /bin.) The busybox replacement of less is a farce.

Also, which version of less does your Pup have? My DPupBuster64 has less
version 487, whereas the most recent is less version 562beta as of this writing.
You can find out the version with

Code: Select all

less --version
Finally, the use of the parameter --color=always with ls or grep may help send
the ANSI codes to less. As explained here:
https://unix.stackexchange.com/question ... red-output
I get colored results with the following pipe, even under lxterminal:

Code: Select all

 ls -g --color=always | less -R -r
IHTH
Attachments
ls_-g_--color.jpg
Please see full command line above.
(102.79 KiB) Downloaded 72 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#7 Post by step »

@jpit3, if you like vim -R as a pager take a look at vimpager for a better experience, such as vim key bindings, color schemes, and syntax highlighting support. I use it in tandem with less. Less is fast and reliable, a workhorse. vimpager is nicer when I want to study something in depth.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#8 Post by musher0 »

Hi.

I just tripped on this while looking for something else.
I had forgotten about it.

Installing lesspipe could help coloring of text to some extent.
https://github.com/wofr06/lesspipe.sh/a ... sspipe.zip
lesspipe is a companion script to less and provides some coloring utiltiies
for less.

Unpack in its own directory
and
enter there with a console.
Type ./configure and then answer the yes / no questions.
Be patient, the list is long!

When finished configuring, copy
lesspipe.sh, code2color, sxw2txt and tarcolor to /usr/local/bin.
Then make a symlink of lesspipe.sh from /usr/local/bin to /usr/bin.

This should facilitate coloring of some text, as well as displaying in the less
viewer texts inside various types of archives. (There is also zless at /bin for
this, IIRC.)

IHTH
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#9 Post by tallboy »

jplt3, I feel really stupid, you asked about less, not ls. Sorry, brainfart!
True freedom is a live Puppy on a multisession CD/DVD.

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#10 Post by Semme »

TB, you must be :mrgreen: MAD! :D:wink:
>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<

Post Reply