Skip to content

CoeJoder/lessfilter-pygmentize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Syntax highlighter for less

Uses Pygments to provide syntax highlighting for supported file types. The .lessfilter is generated by parsing the Pygments documentation website. screenshot

Installation

1. Install Pygments & awk

Ensure that you have the latest version of Pygments installed by using pip, as your distro's packaged version is likely outdated. You'll also need awk.

# remove any installed packaged versions
sudo apt autoremove python-pygments python3-pygments

# install latest version
sudo pip install Pygments --upgrade

# install some implementation of `awk`
sudo apt install gawk

2. Install lesspipe (recommended)

Most Linux distros already have lesspipe enabled, but you can check for certain by running:

echo $LESSOPEN

If you don't see lesspipe or lessfile in the output, install lesspipe.

3. Configure Environment Variables

Add the following to ~/.bashrc

# sets LESSOPEN and LESSCLOSE variables
eval "$(SHELL=/bin/sh lesspipe)"

# interpret color characters
export LESS='-R'

# to list available styles: `pygmentize -L styles`
export PYGMENTIZE_STYLE='paraiso-dark'

# optional
alias ls='ls --color=always'
alias grep='grep --color=always'

If you don't have or want lesspipe, replace the above eval statement with:

export LESSOPEN='|~/.lessfilter %s'

4. Create ~/.lessfilter

Run main.py to generate the latest .lessfilter file and place it in your home directory. Or you can download a pre-generated .lessfilter which is currently at version 2.15.1. Check your program version by running pygmentize -V to ensure that it is this version or newer.

5. Make ~/.lessfilter executable

chmod +x ~/.lessfilter

Done. Test it out by running less ~/.lessfilter

About

A pygments-based syntax highlighter for less.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published