changeset 89:a5810e6bed7e

Improve nano shell colouring
author IBBoard <dev@ibboard.co.uk>
date Mon, 02 Apr 2018 17:15:26 +0100
parents 93b29bcbc9e7
children 4342e7b19fa8
files nanorc nanorc.d/sh.nanorc
diffstat 2 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/nanorc	Mon Apr 02 16:56:31 2018 +0100
+++ b/nanorc	Mon Apr 02 17:15:26 2018 +0100
@@ -22,4 +22,4 @@
 include "~/.nanorc.d/php.nanorc"
 
 ## Bourne shell scripts
-include "/usr/share/nano/sh.nanorc"
+include "~/.nanorc.d/sh.nanorc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nanorc.d/sh.nanorc	Mon Apr 02 17:15:26 2018 +0100
@@ -0,0 +1,31 @@
+## Here is an example for Bourne shell scripts.
+
+syntax sh "\.sh$"
+header "^#!.*((ba|da|k|pdk)?sh[-0-9_]*|openrc-run|runscript)"
+magic "(POSIX|Bourne-Again) shell script.*text"
+linter dash -n
+comment "#"
+
+icolor cyan "^[0-9A-Z_]+\(\)"
+color cyan "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
+color cyan "\<(declare|eval|exec|export|let|local)[[:space:]]\>"
+color cyan "[{}():;|`$<>!=&\\]" "(\]|\[)"
+color cyan "(function )?[a-zA-Z0-9_]+[[:space:]]*\(\)"
+color cyan "-[Ldefgruwx]\>"
+color red "-(eq|ne|gt|lt|ge|le|s|n|z)\>"
+color red "&&|\|\|"
+color brightblue "\<(awk|cat|cd|ch(grp|mod|own)|cp|echo|env|grep|install|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|umask|unset)\>"
+
+# Basic variable names (no braces).
+color magenta "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
+# More complicated variable names; handles braces and replacements and arrays.
+color magenta "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:space:]]*[[:alnum:]_]+[[:space:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
+
+# Strings.
+color yellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
+
+# Comments.
+color green "(^|[[:space:]])#.*$"
+
+# Trailing whitespace.
+color ,green "[[:space:]]+$"