Syntax highlighting is a useful tool and nowadays a common feature with many text editors. Syntax highlighting is available with some Linux text pagers too although not always directly. The most popular pager with Linux probably is the
Searching the web finds many articles about adding syntax highlighting with
less, including adding color to man pages. The common advice to providing syntax highlighting with
less is the
source-highlight package. There are some caveats with this solution — some of the colors are difficult to read with a black background and syntax highlighting does not function with certain files.
With Slackware some of the usability problems include:
/var/log/syslogdisplays the date/time stamp in a dark blue that is almost unreadable with a black background.
/var/log/messagesresults in no highlighting at all, despite having the same file format as
- Viewing the Slackware
ChangeLog.txtfile does not highlight dates/times and has the same dark blue readability problem.
Other files have similar issues.
Editing the following files help some by changing the colors, such as
Part of the problem is the package seems designed from the perspective of the Debian distro. Thus the Slackware
ChangeLog.txt file is not recognized as a changelog file nor is the
/var/log/messages file recognized as a log file.
/usr/bin/src-hilite-lesspipe.sh helps by changing the case statement from
Adding another case statement helps resolve the issues with various system log files:
*syslog*|*messages*|*dnsmasq*|*cron*|*debug*|*kernel*|*maillog*|*secure*) source-highlight —failsafe -f esc —lang-def=log.lang —style-file=esc.style -i "$source" ;;
Improving the highlighting with the Slackware ChangeLog.txt requires editing
changelog.lang. This is done by replacing the date/time formatting with a more robust snippet from the
A complete patch is available here.