User:Maffblaster/Drafts/Colorize everything

From Gentoo Wiki
Jump to:navigation Jump to:search

This article provides configuration information, sometimes links to other articles, so that all the things may be colorized.

Software that can be colorized

sys-apps

less

less requires some extra help by using a syntax highlighter as an input preprocessor (see the LESSOPEN and/or LESSCLOSE environment variables for more details) in order to colorize output. For this example, pygments will used in order to help colorize less' output.

Create a custom ~/.lesspipe file. Gentoo provides a lesspipe file (/usr/bin/lesspipe with the less package itself (sys-apps/less). This file will be automatically sourced by bash, due to the /etc/env.d/70less file.

FILE ~/.lesspipe
#!/bin/sh
case "${1}" in
    *.ad[asb]|*.asm|*.awk|*.axp|*.cc|*.[ch]|*.[ch]pp|*.[ch]xx|*.diff|*.ebuild|*.eclass|*.groff|*.inc|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.hh|*.lsp|*.l|*.pas|*.p|*.patch|*.pov|*.ppd|*.py|*.rb|*.sh|*.sql|*.vim|*.xml|*xorg.conf|*.xps|*.xsl)
        pygmentize -f 256 "${1}";;

    .bashrc|.bash_aliases|.bash_profile|.bash_environment)
        pygmentize -f 256 -l sh "${1}";;

    .vimrc)
        pygmentize -f 256 -l vim "${1}";;

    *)
        if grep -q "#\!/bin/bash" "${1}" 2>&1 /dev/null; then
            pygmentize -f 256 -l sh "${1}"
        else
            exit 1
        fi
esac

exit 0

Make the new file executable:

user $chmod u+x ~/.lesspipe

Modify the shell's run command file. In this case, bash:

FILE ~/.bashrc
export LESS='-R'
export LESSOPEN='|~/.lesspipe %s'

sys-editors

nano

See Nano#Syntax_highlighting.

vim

Coming soon...