diff --git a/demo/src/main/java/org/jline/demo/Repl.java b/demo/src/main/java/org/jline/demo/Repl.java index 069e136ff..d9d0743f5 100644 --- a/demo/src/main/java/org/jline/demo/Repl.java +++ b/demo/src/main/java/org/jline/demo/Repl.java @@ -284,15 +284,21 @@ public static void main(String[] args) { systemRegistry.addCompleter(scriptEngine.getScriptCompleter()); systemRegistry.setScriptDescription(scriptEngine::scriptDescription); // - // LineReader + // Command line highlighter // Path jnanorc = configPath.getConfig("jnanorc"); SyntaxHighlighter commandHighlighter = SyntaxHighlighter.build(jnanorc,"COMMAND"); SyntaxHighlighter argsHighlighter = SyntaxHighlighter.build(jnanorc,"ARGS"); SyntaxHighlighter groovyHighlighter = SyntaxHighlighter.build(jnanorc,"Groovy"); SystemHighlighter highlighter = new SystemHighlighter(commandHighlighter, argsHighlighter, groovyHighlighter); + if (!OSUtils.IS_WINDOWS) { + highlighter.setSpecificHighlighter("!", Nano.SyntaxHighlighter.build(jnanorc, "SH-REPL")); + } highlighter.addFileHighlight("nano", "less", "slurp"); highlighter.addFileHighlight("groovy", "classloader", Arrays.asList("-a", "--add")); + // + // LineReader + // LineReader reader = LineReaderBuilder.builder() .terminal(terminal) .completer(systemRegistry.completer()) diff --git a/demo/src/main/scripts/sh-repl.nanorc b/demo/src/main/scripts/sh-repl.nanorc new file mode 100644 index 000000000..53f911f47 --- /dev/null +++ b/demo/src/main/scripts/sh-repl.nanorc @@ -0,0 +1,19 @@ +## Groovy REPL sh commands highlight. +## +syntax "SH-REPL" + +## keywords: +color green "\<(case|do|done|elif|else|esac|fi|for|function|if|in|select|then|time|until|while)\>" +color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)" +color green "-[Lldefgrtuwx]+\>" +color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>" +## builtins: +color brightblue "\<(alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|compopt|continue|declare|dirs|disown|echo|enable|eval|exec|exit|export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|local|logout|mapfile|popd|printf|pushd|pwd|read|readarray|readonly|return|set|shift|shopt|source|suspend|test|times|trap|true|type|typeset|ulimit|umask|unalias|unset|wait)\>" +## not buitins: +color brightblue "\<(cat|chmod|chown|cp|env|grep|install|ln|make|mkdir|mv|rm|sed|tar|touch|ls)\>" +icolor brightgreen "^\s+[0-9A-Z_]+\s+\(\)" +icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?" +color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'" +color cyan "^([[:space:]])*#.*$" +color cyan start="/\*" end="\*/" +# color ,green "[[:space:]]+$"