Created
July 27, 2015 08:53
-
-
Save karolyi/ad020e676e989678d16e to your computer and use it in GitHub Desktop.
256 color source highlight for less on FreeBSD terminals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension "txt" | |
# Path: /usr/local/share/source-highlight/ | |
styletemplate "\x1b[$stylem$text\x1b[m" | |
color "00;38;05;$style" | |
colormap | |
"blue" "75" | |
"darkblue" "33" | |
"gray" "242" | |
"green" "70" | |
"orange" "208" | |
"purple" "171" | |
"red" "196" | |
"white" "255" | |
"yellow" "226" | |
default "255" | |
end | |
#################### | |
# Code color help | |
##################### | |
# 256 code color control template: | |
# Code : \033[AA;FF;BBm | |
# AA (attributes) : 00|01|03|04|05|07|22|23|24|25|27 | |
# FF (foreground) : 38;05;color | |
# BB (background) : 48;05;color | |
# color : 000-255 | |
# Attributes meaning | |
# 00 Reset | |
# 01 Bold | |
# 03 Italic | |
# 04 Underline | |
# 05 Blink (doesn't work when a background is set) | |
# 07 Reverse (swap foreground and background) | |
# 22 No Bold | |
# 23 No Italic | |
# 24 No Underline | |
# 25 No Blink | |
# 27 No Reverse | |
# Any of AA,FF,BB may be omited. | |
# Reset code (default color/attribute): \033[m | |
# Examples: | |
# -> Hello world in color 226 (=> yellow): | |
# echo -e "\033[38;05;226mHello, World" | |
# -> Hello world in bold blanking yellow: | |
# echo -e "\033[01;05;38;05;226mHello, World" | |
# -> Hello world in bold yellow with a red background: | |
# echo -e "\033[01;38;05;226;48;05;196mHello, World" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// path: /usr/local/share/source-highlight/ | |
classname orange ; | |
comment gray ; | |
function blue; | |
keyword purple ; | |
preproc darkblue ; | |
regexp orange ; | |
string red ; | |
todo yellow ; | |
type green ; | |
usertype orange ; | |
variable green ; | |
// diff files | |
oldfile red ; | |
newfile green ; | |
difflines darkblue ; | |
// ChangeLog and log files | |
date blue ; | |
file red ; | |
ip orange ; | |
name green ; | |
time darkblue ; | |
// line numbers | |
linenum yellow ; | |
// Internet related | |
url blue ; | |
// for css | |
selector purple ; | |
property blue ; | |
value green ; | |
// ===== Useless ===== | |
// cbracket | |
// normal | |
// number | |
// specialchar | |
// symbol | |
// ==== | |
// for feature (Cucumber) files | |
cuketag green ; | |
gherken blue ; | |
given red ; | |
when cyan ; | |
then yellow ; | |
and_but pink ; | |
table gray ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check system messages | |
msgs -q | |
# Allow terminal messages | |
mesg y | |
EDITOR='vim' | |
CLICOLOR='y' | |
PAGER=less | |
LSCOLORS=ExFxCxDxBxegedabagacad | |
WRKDIRPREFIX=/root/portsworkdir | |
DISTDIR=/root/portsworkdir/distfiles | |
PACKAGES=/root/portsworkdir/packages | |
LESSOPEN="| /usr/local/etc/source-highlight-esc/source-highlight-esc.sh %s" | |
LESS=' -R ' | |
export EDITOR PAGER CLICOLOR LSCOLORS WRKDIRPREFIX DISTDIR PACKAGES LESSOPEN LESS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Path: /usr/local/etc/source-highlight-esc/ | |
# Detect how many colors the terminal supports so source-highlight can | |
# output in 256. | |
# Copyright 2012 Xavier-Emmanuel VINCENT | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
colors=$(tput Co) # FreeBSD flavor | |
# /dev/tty doesn't support 256 colors => check $DISPLAY | |
if [ "${colors}" -eq 256 ] | |
then | |
NB="256" | |
else | |
NB="" | |
fi | |
source-highlight --outlang-def=esc${NB}.outlang --style-file=esc${NB}.style -i "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment