Created
November 15, 2013 20:24
-
-
Save pjdietz/7490982 to your computer and use it in GitHub Desktop.
Syntax Highlighting for configuration files in Nano
This file contains 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
# From https://bbs.archlinux.org/viewtopic.php?id=133595 | |
# To use, store to /usr/share/nano/conf.nanorc | |
# Add the following line to ~/.nanorc | |
# include include /usr/share/nano/conf.nanorc | |
# config file highlighting | |
syntax "conf" "(\.(conf|config|cfg|cnf|rc|lst|list|defs|ini|desktop|mime|types|preset|cache|seat|service|htaccess)$|(^|/)(\w*crontab|mirrorlist|group|hosts|passwd|rpc|netconfig|shadow|fstab|inittab|inputrc|protocols|sudoers)$|conf.d/|.config/)" | |
# default text | |
color magenta "^.*$" | |
# special values | |
icolor brightblue "(^|\s|=)(default|true|false|on|off|yes|no)(\s|$)" | |
# keys | |
icolor cyan "^\s*(set\s+)?[A-Z0-9_\/\.\%\@+-]+\s*([:]|\>)" | |
# commands | |
color blue "^\s*set\s+\<" | |
# punctuation | |
color blue "[.]" | |
# numbers | |
color red "(^|\s|[[/:|<>(){}=,]|\])[-+]?[0-9](\.?[0-9])*%?($|\>)" | |
# keys | |
icolor cyan "^\s*(\$if )?([A-Z0-9_\/\.\%\@+-]|\s)+=" | |
# punctuation | |
color blue "/" | |
color brightwhite "(\]|[()<>[{},;:=])" | |
color brightwhite "(^|\[|\{|\:)\s*-(\s|$)" | |
# section headings | |
icolor brightyellow "^\s*(\[([A-Z0-9_\.-]|\s)+\])+\s*$" | |
color brightcyan "^\s*((Sub)?Section\s*(=|\>)|End(Sub)?Section\s*$)" | |
color brightcyan "^\s*\$(end)?if(\s|$)" | |
# URLs | |
icolor green "\b(([A-Z]+://|www[.])[A-Z0-9/:#?&$=_\.\-]+)(\b|$| )" | |
# XML-like tags | |
icolor brightcyan "</?\w+((\s*\w+\s*=)?\s*("[^"]*"|'[^']*'|!?[A-Z0-9_:/]))*(\s*/)?>" | |
# strings | |
color yellow "\"(\\.|[^"])*\"" "'(\\.|[^'])*'" | |
# comments | |
color white "#.*$" | |
color blue "^\s*##.*$" | |
color white "^;.*$" | |
color white start="<!--" end="-->" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment