Syntax Highlighting with nano – nanorc for changelogs

## Changelog file syntax
##
syntax "changelogs" "ChangeLog*$" "HISTORY$" "NEWS$"
 
color green "\+"
color red "\-"
color brightwhite "[0-9]"
color brightblue "[0-9][0-9]\:[0-9][0-9]\:[0-9][0-9]"
color blue "[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]"
color blue "[0-9][0-9][0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]"
color blue "\<(CEST|CET|CST||CDT|EDT)\>"
color yellow "[0-9]\..*$"
color cyan "\*.*$"
color brightblue "\<(pre.*$|beta.*$|rc.*$|release.*$)\>"
color green "#.*$"
icolor brightred "^[[:space:]]*[.0-9A-Z_]*:"
color magenta "[.0-9A-Za-z_]*[[:space:]]*[.0-9A-Za-z_]*[[:space:]]<"
color brightyellow  "<(\\.|[^\"])*>"
color brightwhite "commit[[:space:]]*[.0-9A-Z_]*$"

Syntax Highlighting with nano – nanorc for changelog

syntax "changelog" "ChangeLog$"
color brightgreen "^\+.*"
color green "^\+\+\+.*"
color brightblue "^ .*"
color brightred "^-.*"
color red "^---.*"
color red "(\d\d\s\w\+\s\d\{4\})"
color brightyellow "^@@.*"
color magenta "^diff.*"
 
#syn region GentooChangeLogRelease start=/^\*/ end=/$/ contains=GentooChangeLogReleaseDate
#syn match GentooChangeLogReleaseDate contained /(\d\d\s\w\+\s\d\{4\})/
#syn region GentooChangeLogEntry start=/^\s\+/ end=/\n\n/
#           \ contains=GentooChangeLogEntryDate,GentooBug
#syn region GentooChangeLogEntryDate contained start=/\d\?\d\s\w\+\s\d\{4\}/ end=/;/
#           \ nextgroup=GentooChangeLogEntryAuthor,GentooChangeLogEntryEmail skipwhite skipnl
#syn region GentooChangeLogEntryAuthor contained start=/\S/ end=/\( <\)\@=/
#           \ nextgroup=GentooChangeLogEntryEmail skipwhite skipnl
#syn match  GentooChangeLogEntryEmail contained /<\?[a-zA-Z0-9\.\-\_]\+@[a-zA-Z0-9\.\-\_]\+>\?/
#           \ nextgroup=GentooChangeLogFiles skipwhite skipnl
#syn region GentooChangeLogFiles contained start=/\(\S\)\@=/ end=/:/
#           \ contains=GentooChangeLogAddFile,GentooChangeLogDelFile,GentooChangeLogModFile
#" Add / delete / changed files
#syn region GentooChangeLogAddFile contained start=/+/ end=/\([,:]\)\@=/
#syn region GentooChangeLogDelFile contained start=/-/ end=/\([,:]\)\@=/
#syn region GentooChangeLogModFile contained start=/[a-zA-Z0-9]/ end=/\([,:]\)\@=/

Syntax Highlighting with nano – nanorc for c

## Here is an example for C/C++.
##
syntax "c" "\.(c(c|pp|xx)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$"
color brightred "\<[A-Z_][0-9A-Z_]+\>" 
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\>"
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
color magenta "\<(goto|continue|break|return)\>"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
##
## GCC builtins
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
##
## String highlighting.  You will in general want your comments and
## strings to come last, because syntax highlighting rules will be
## applied in the order they are read in.
color brightyellow "<[^= 	]*>" ""(\\.|[^"])*""
##
## This string is VERY resource intensive!
color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
 
## Comment highlighting
color brightblue "//.*"
color brightblue start="/\*" end="\*/"

Syntax Highlighting with nano – nanorc for awk

## Here is an example for awk.
##
syntax "awk" "\.awk$"
## records
icolor brightred "\$[0-9A-Z_!@#$*?-]+"
## awk-set variables
color red "\<(ARGC|ARGIND|ARGV|BINMODE|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS)\>"
color red "\<(FILENAME|FNR|FS|IGNORECASE|LINT|NF|NR|OFMT|OFS|ORS)\>"
color red "\<(PROCINFO|RS|RT|RSTART|RLENGTH|SUBSEP|TEXTDOMAIN)\>"
## function declarations and special patterns
color brightgreen "\<(function|extension|BEGIN|END)\>"
## operators
color green "(\{|\}|\(|\)|\;|\]|\[|\\|<|>|!|=|&|\+|-|\*|%|/|\?:|\^|\|)"
## flow control
color brightyellow "\<(for|if|while|do|else|in|delete|exit)\>"
color brightyellow "\<(break|continue|return)\>"
## I/O statements
color brightgreen "\<(close|getline|next|nextfile|print|printf)\>"
color brightgreen "\<(system|fflush)\>"
## standard functions
color magenta "\<(atan2|cos|exp|int|log|rand|sin|sqrt|srand)\>"
color magenta "\<(asort|asorti|gensub|gsub|index|length|match)\>"
color magenta "\<(split|sprintf|strtonum|sub|substr|tolower|toupper)\>"
color magenta "\<(mktime|strftime|systime)\>"
color magenta "\<(and|compl|lshift|or|rshift|xor)\>"
color magenta "\<(bindtextdomain|dcgettext|dcngettext)\>"
 
##
## String highlighting.  You will in general want your comments and
## strings to come last, because syntax highlighting rules will be
## applied in the order they are read in.
color brightyellow "<[^= 	]*>" ""(\\.|[^"])*""
 
## Comment highlighting
color brightblue "(^|[[:space:]])#.*$"
 
## Trailing whitespace
color ,green "[[:space:]]+$"

Syntax Highlighting with nano – nanorc for asm

## Here is an example for assembler.
##
syntax "asm" "\.(S|s|asm)$"
color red "\<[A-Z_]{2,}\>"
color brightgreen "\.(data|subsection|text)"
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
icolor brightred "^[[:space:]]*[.0-9A-Z_]*:"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
## Highlight strings (note: VERY resource intensive)
color brightyellow "<[^= 	]*>" ""(\\.|[^"])*""
color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
## Highlight comments
color brightblue "//.*"
color brightblue start="/\*" end="\*/"

Syntax Highlighting with nano – nanorc for vhost

## Apache httpd.conf highlighting
##
#how to add sites-enabled files?  "default" is too generic to keep in here I think
syntax "vhost" "(\.|/|)vhost\.conf"
color brightwhite "(ServerRoot|(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)|Start(Threads|Servers))"
color yellow "(MaxClients|(Max)?ThreadsPerChild|MaxRequestsPerChild)"
color yellow "(FancyIndexing|VersionSort|ExecCGI|FollowSymLinks)"
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)\>"

Syntax Highlighting with nano – nanorc for Apache

## Apache httpd.conf highlighting
##
#how to add sites-enabled files?  "default" is too generic to keep in here I think
syntax "Apache2" "apache2\.conf$" "httpd\.conf$" "default"
color brightwhite "(ServerRoot|(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 yellow "(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)|Start(Threads|Servers))"
color yellow "(MaxClients|(Max)?ThreadsPerChild|MaxRequestsPerChild)"
color yellow "(FancyIndexing|VersionSort|ExecCGI|FollowSymLinks)"
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:]]*#.*"

Installation of nano on fun_plug 0.5 for CH3SNAS, CH3MNAS, DNS-323 and many more

This tutorial is deprecated and should only be used with fonz fun_plug 0.5!
Please check the tutorial page for updated tutorials on this topic!

After the installation of the fun_plug the only available editor is “vi”, which is not really considered a “newbie“-friendly editor. The nano editor is much easier to use and largely self-explanatory. If you nevertheless want more information on the GNU nano editor, see its home page.

Installation

In this tutorial we assume that the fun_plug is already installed on the NAS and that you synchronized Uli’s repository (see here for instructions on how to do this). Afterwards install the package (see detailed instructions here):

funpkg -i /ffp/pkg/additional/app-editors/nano*.tgz

Move the configuration-file nanorc from /ffp/etc/examples/ to /ffp/etc/ to get syntax highlighting.

mv /ffp/etc/examples/nanorc /ffp/etc/

Usage

Screenshot of nano running in a PuTTY window
Simply enter “nano ” on the commandline (replacing "" with the name of the file you want to edit).

Basic commands

The commands are shown at the bottom of the nano screen. The main commands are:

  • CTRL + G => Get Help
  • CTRL + O => WriteOut (“Save”)
  • CTRL + W => Where Is (Search for a string in the file)
  • CTRL + C => Cur Pos (Shows the line & column number of the current cursor-position)
  • CTRL + X => Exit (Self explanatory)
  • CTRL + T => Spell checking (if aspell is installed)

Syntax highlighting

To have syntax highlighting for a certain language you have to uncomment it in /ffp/etc/nanorc. Example for PHP:
Search:

## PHP
#include "/ffp/share/nano/php.nanorc"

And remove the comment like this:

## PHP
include "/ffp/share/nano/php.nanorc"
Exit mobile version