Skip to content

Instantly share code, notes, and snippets.

@vigo
Created March 15, 2011 10:59
Show Gist options
  • Save vigo/870590 to your computer and use it in GitHub Desktop.
Save vigo/870590 to your computer and use it in GitHub Desktop.
Nano config file
## .css
##############################################################################
syntax "css" "\.css$"
color brightred "."
color brightyellow start="\{" end="\}"
color brightwhite start=":" end="[;^\{]"
color brightblue ":active|:focus|:hover|:link|:visited|:link|:after|:before|$"
color brightblue start="\/\*" end="\\*/"
color green ";|:|\{|\}"
##############################################################################
## .html
##############################################################################
syntax "html" "\.html$"
color blue start="<" end=">"
color red "&[^;[[:space:]]]*;"
##############################################################################
## .conf (Apache)
##############################################################################
syntax "Apache2" "\.conf$"
color brightwhite "(ServerRoot|LoadModule|(Lock|Pid)File|Timeout|(Max)?KeepAlive(Requests|Timeout)?)"
color brightwhite "(User|Group|LogFormat|ErrorLog|Include|(Script)?Alias)"
color brightwhite "(ErrorDocument|AccessFileName|UseCanonicalName|TypesConfig|DefaultType)"
color brightwhite "(HostnameLookups|IndexOptions|(Readme|Header)Name|LanguagePriority)"
color brightwhite "(AddIcon(ByEncoding|ByType)?|DefaultIcon|IndexIgnore|BrowserMatch)"
color brightwhite "(Add(Encoding|Language|(Default)?Charset|Type|Handler)|DirectoryIndex)"
color brightwhite "(DocumentRoot|Server(Admin|Signature)|LogLevel|CustomLog)"
color brightwhite "((Force)?LanguagePriority|NameVirtualHost)"
color brightyellow "(SetHandler|Order|Deny|Allow|SetOutputFilter)"
color yellow "(AllowOverride|FileInfo|AuthConfig|Limit)"
color yellow "([^A-Z0-9a-z]Options|Indexes|(\+|\-)?SymLinksIfOwnerMatch)"
color yellow "(Includes(NoExec)?|(\+|\-)?MultiViews)"
color yellow "(None|allow,deny|deny,allow|(allow)? from (all)?|Prefer|Fallback)"
color yellow "(Add(Handler|OutputFilter)|NumServers|AcceptMutex)"
color yellow "((Min|Max)Spare(Threads|Servers|Processors)|Start(Threads|Servers))"
color yellow "(MaxClients|(Min|Max)?ThreadsPerChild|MaxRequestsPerChild)"
color yellow "(FancyIndexing|FoldersFirst|XHTML|Charset|HTMLTable|NameWidth|VersionSort|ExecCGI|FollowSymLinks|(Min|Max)Processors)"
color yellow "hostmaster@[A-Za-z0-9\.]*"
color brightred "(On|Off)[[:space:]]*$"
color brightred "[[:space:]]+(debug|info|notice|warn|error|crit|alert|emerg)[[:space:]]*$"
color brightred "[[:space:]]+(combined|common|referer|agent)[[:space:]]*$"
color brightred "[[:space:]]+(redirect\-carefully|nokeepalive)[[:space:]]*"
color brightred "[[:space:]]+(force\-response\-1\.0)[[:space:]]*"
color brightred "[[:space:]]+(downgrade\-1\.0)[[:space:]]*"
color brightred "[[:space:]]+application/[a-zA-Z\-]+[[:space:]]*"
color brightred "[[:space:]]+type-map[[:space:]]*"
color magenta "[[:space:]]+[0-9]+[[:space:]]*"
color magenta "(/)?(2[0-5]{2}|1[0-9]{2}|[1-9][0-9]|[1-9])(\.(2[0-5]{2}|1[0-9]{2}|[1-9][0-9]|[0-9])){3}([[:space:]]+::(2[0-5]{2}|1[0-9]{2}|[1-9][0-9]|[0-9])/(2[0-5]{2}|1[0-9]{2}|[1-9][0-9]|[0-9]))?"
color brightcyan start="<" end=">"
color white ""(\\.|[^\"])*""
# Unix-based paths
# can't use \] in the regex for some reason?!? Maybe a bug?
# this is preventing a 100% "to the end of the line" match for a few
# lines (the trailing characters from ] to the EOL are not highlighted.
# if anyone knows how to make it work, let me know.. ;)
color white "[[:space:]]+(/[/\[\^#A-Za-z0-9\.\*\_\-]+)+"
color green "^[[:space:]]*#.*"
color cyan "\<(ServerName|Serveralias|DocumentRoot|DirectoryIndex|ErrorLog|CustomLog)\>"
##############################################################################
## .sh
##############################################################################
syntax "sh" "\.sh$"
icolor brightgreen "^[0-9A-Z_]+\(\)"
color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\>"
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
color green "-[Ldefgruwx]\>"
color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>"
color brightblue "\<(cat|cd|chmod|chown|cp|echo|env|export|grep|install|let|ln|make|mkdir|mv|rm|sed|set|tar|touch|umask|unset)\>"
icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color cyan "(^|[[:space:]])#.*$"
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
##############################################################################
## .rb
##############################################################################
syntax "ruby" "\.rb$"
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>"
color brightblue "(\$|@|@@)?\<[A-Z]+[0-9A-Z_a-z]*"
icolor magenta "([ ]|^):[0-9A-Z_]+\>"
color brightyellow "\<(__FILE__|__LINE__)\>"
color brightmagenta "/([^/]|(\\/))*/[iomx]*" "%r\{([^}]|(\\}))*\}[iomx]*"
color brightblue "`[^`]*`" "%x\{[^}]*\}"
color green ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "%[QW]?<[^>]*>" "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!"
color brightgreen "#\{[^}]*\}"
color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!"
color cyan "#[^{].*$" "#$"
color brightcyan "##[^{].*$" "##$"
color green start="<<-?'?EOT'?" end="^EOT"
color brightcyan "(XXX|TODO|FIXME|\?\?\?)"
##############################################################################
## .py
##############################################################################
syntax "python" "\.py$"
icolor brightblue "def [0-9A-Z_]+"
color brightcyan "\<(and|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|map|not|or|pass|print|raise|return|try|while)\>"
color brightgreen "["'].*[^\\]["']" "["']{3}.*[^\\]["']{3}"
color brightgreen start=""""[^"]" end=""""" start="'''[^']" end="'''"
color brightred "#.*$"
##############################################################################
## nanorc, .nanorc
##############################################################################
syntax "nanorc" "\.?nanorc$"
icolor brightwhite "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace|wordbounds)\>"
icolor green "^[[:space:]]*(set|unset|include|syntax)\>"
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
icolor white ""(\\.|[^"])*""
icolor brightblue "^[[:space:]]*#.*$"
icolor cyan "^[[:space:]]*##.*$"
##############################################################################
## .pl, .pm, .pl
##############################################################################
syntax "perl" "\.p[lm]$"
color red "\<(accept|alarm|atan2|bin(d|mode)|c(aller|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))\>" "\<(get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)\>" "\<(keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek(dir)?)\>" "\<(se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr(y)?|truncate|umask)\>" "\<(un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\>"
color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne|lt|gt|le|ge|cmp|x|my|sub|use|package|can|isa)\>"
icolor cyan start="[$@%]" end="( |[^0-9A-Z_]|-)"
color yellow "".*"|qq\|.*\|"
color white "[sm]/.*/"
color white start="(^use| = new)" end=";"
color green "#.*"
color yellow start="<< 'STOP'" end="STOP"
##############################################################################
## .php, .php2, .php3, .php4, .php5, .php(s), .phtml
##############################################################################
syntax "php" "\.php$" "\.php[2345s]$" "\.phtml$"
#functions
color brightmagenta "([A-Za-z0-9])"
#numbers
color brightblue "[0-9]"
#special
color brightwhite "(^|[^A-Za-z0-9])(<\?php|\?>|var|and|or|default|class|extends|true|false|global|function|new|switch|case|break|next|prev|elseif|if|else|foreach|for|as|do|while|exit|die|declare|require_once|require|include_once|include|return|echo|static|array|isset)([^A-Za-z0-9])"
#types
color brightred "([^A-Za-z0-9])|[^A-Za-z](null|int|string|float|bool|object|resource)[^A-Za-z0-9_]+[^A-Za-z]"
#strings
color brightyellow ""(\\.|[^\"])*""
color brightyellow "'(\\.|[^\'])*'"
#Variables
color brightcyan "\$[]\[A-Za-z0-9_'\"]*"
#comments
color green "//.*"
color green "#.*"
color green start="/\*" end="\*/"
##############################################################################
# xhtml, xml, sgml, shtml and more...
##############################################################################
syntax "ml" ".*\.([jrs]?html?|xml|sgml?)$"
color white "^.+$"
color green start="<" end=">"
color cyan "<[^> ]+"
color cyan ">"
color yellow start="<!DOCTYPE" end="[/]?>"
color yellow start="<!--" end="-->"
color red "&[^;]*;"
##############################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment