Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
I want less out of less
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
curmudgeon
Veteran
Veteran


Joined: 08 Aug 2003
Posts: 1741

PostPosted: Fri Jan 06, 2006 6:49 am    Post subject: I want less out of less Reply with quote

A new version of less got marked stable recently
with less than happy results, at least for me.

It seems that less now tries to display with syntax
(a la vim). At first:

Code:
$ less /usr/bin/lesspipe.sh

ESC[32m#!/bin/bashESC[0m
ESC[34m#ESC[0m
ESC[34m# Preprocessor for 'less'. Used when this environment variable is set:
# LESSOPEN="|lesspipe.sh %s"ESC[0m

ESC[34m# TODO: handle compressed files better
ESC[0m
trap 'exit 0' PIPE

guesscompress() {
        case ESC[31m"ESC[36m$1ESC[0m" in
                *.gz)  echo ESC[31m"gunzip -c"ESC[0m ;;
                *.bz2) echo ESC[31m"bunzip2 -c"ESC[0m ;;
                *.Z)   echo ESC[31m"compress -d"ESC[0m ;;
                *)     echo ESC[31m"cat"ESC[0m ;;
        esac
}

lesspipe_file() {
        local ESC[36mESC[36moutESC[0m=$(file -L -- ESC[31m"ESC[36m$1ESC[0m")
        case ${out} in
                *ESC[31m" ar archive"ESC[0m*)    lesspipe ESC[31m"ESC[36m$1ESC[0m" ESC[31m".a"ESC[0m ;;
                *ESC[31m" tar archive"ESC[0m*)   lesspipe ESC[31m"ESC[36m$1ESC[0m" ESC[31m".tar"ESC[0m ;;
                *ESC[31m" CAB-Installer"ESC[0m*) lesspipe ESC[31m"ESC[36m$1ESC[0m" ESC[31m".cab"ESC[0m ;;
                *ESC[31m" troff "ESC[0m*)        lesspipe ESC[31m"ESC[36m$1ESC[0m" ESC[31m".man"ESC[0m ;;
                *ESC[31m" shared object"ESC[0m*) lesspipe ESC[31m"ESC[36m$1ESC[0m" ESC[31m".so"ESC[0m ;;
                *ESC[31m" Zip archive"ESC[0m*)   lesspipe ESC[31m"ESC[36m$1ESC[0m" ESC[31m".zip"ESC[0m ;;
                *ESC[31m" LHa"ESC[0m*archive*)   lesspipe ESC[31m"ESC[36m$1ESC[0m" ESC[31m".lha"ESC[0m ;;
                *ESC[31m" ELF "ESC[0m*)          readelf -a -- ESC[31m"ESC[36m$1ESC[0m" ;;
                *ESC[31m": data"ESC[0m)          hexdump -C -- ESC[31m"ESC[36m$1ESC[0m" ;;
                *)                  return 1 ;;
        esac
        return 0
}


Blech!

A quick look at the man page tells me that -R
(or -r) will display this as intended, but I would
rather turn the whole thing off (have no syntax
highlighting whatsoever). How do I do that?

Thank you in advance.

P.S. I tried searching the forum for less, but
that returned zero results, probably as less
appears on some list of common words.
Back to top
View user's profile Send private message
dasilva
Tux's lil' helper
Tux's lil' helper


Joined: 20 Oct 2004
Posts: 83

PostPosted: Fri Jan 06, 2006 7:01 am    Post subject: Reply with quote

in your ~/.bash_profile put
Code:

alias less='less -R'


man alias for more information. The alias command can also be useful for making nano always start with -w, among other things ;)

hope that helps.
Back to top
View user's profile Send private message
Dlareh
Advocate
Advocate


Joined: 06 Aug 2005
Posts: 2102

PostPosted: Fri Jan 06, 2006 7:19 am    Post subject: Reply with quote

dasilva wrote:
in your ~/.bash_profile put
Code:

alias less='less -R'


man alias for more information. The alias command can also be useful for making nano always start with -w, among other things ;)

hope that helps.

Actually, the environment variable LESS is a better way to control its behavior. For instance mine is:

Code:
LESS='-R -M --shift 5'


P.S. curmudgeon, please do not insert line breaks (press enter) in the middle of sentences when posting to the WWW.
_________________
"Mr Thomas Edison has been up on the two previous nights discovering 'a bug' in his phonograph." --Pall Mall Gazette (1889)
Are we THERE yet?
Back to top
View user's profile Send private message
curmudgeon
Veteran
Veteran


Joined: 08 Aug 2003
Posts: 1741

PostPosted: Fri Jan 06, 2006 7:48 am    Post subject: Reply with quote

First of all, do line breaks cause some problem I don't know about? I have a very wide monitor, and having line breaks just makes it easier for me to read. :)

Putting the parameters in the .lesskey file works even better (the whole purpose for that file), but that does NOT tell me how to TURN OFF syntax highlighting. The -R parameter will display it correctly, but I don't want it at all. I want to see the file without any color whatsoever. How do I do that?
Back to top
View user's profile Send private message
Dlareh
Advocate
Advocate


Joined: 06 Aug 2005
Posts: 2102

PostPosted: Fri Jan 06, 2006 8:04 am    Post subject: Reply with quote

use "export LESSCOLOR=0"

I too have a very large monitor, so your line breaks cause your text to display using less than 10% of my screen width, which I find extremely annoying and uncomfortable to read. Automatic word wrap allows everyone to size their browser windows to suit their own tastes.... you should make your windows narrower when posting, if this helps you. I think anything that uses a fixed width for text (many news sites, for instance) are an abomination.
_________________
"Mr Thomas Edison has been up on the two previous nights discovering 'a bug' in his phonograph." --Pall Mall Gazette (1889)
Are we THERE yet?
Back to top
View user's profile Send private message
curmudgeon
Veteran
Veteran


Joined: 08 Aug 2003
Posts: 1741

PostPosted: Fri Jan 06, 2006 7:29 pm    Post subject: Reply with quote

Dlareh wrote:
use "export LESSCOLOR=0"


Well that worked (thanks). Where the !@#$%^&* is that documented? I couldn't find it anywhere even after your post.
Back to top
View user's profile Send private message
Dlareh
Advocate
Advocate


Joined: 06 Aug 2005
Posts: 2102

PostPosted: Sat Jan 07, 2006 8:16 am    Post subject: Reply with quote

curmudgeon wrote:
Dlareh wrote:
use "export LESSCOLOR=0"


Well that worked (thanks). Where the !@#$%^&* is that documented? I couldn't find it anywhere even after your post.

lesspipe.sh -h, though I actually got it by reading line 142
_________________
"Mr Thomas Edison has been up on the two previous nights discovering 'a bug' in his phonograph." --Pall Mall Gazette (1889)
Are we THERE yet?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum