module Rouge module Lexers ShellLexer = RegexLexer.create do name 'shell' aliases 'bash', 'zsh', 'ksh', 'sh' KEYWORDS = %w( if fi else while do done for then return function case select continue until esac elif ).join('|') BUILTINS = %w( alias bg bind break builtin caller cd command compgen complete declare dirs disown echo enable eval exec exit export false fc fg getopts hash help history jobs kill let local logout popd printf pushd pwd read readonly set shift shopt source suspend test time times trap true type typeset ulimit umask unalias unset wait ).join('|') lexer :basic do rule /#.*\n/, 'Comment' rule /\b(#{KEYWORDS})\s*\b/, 'Keyword' rule /\b(#{BUILTINS})\s*\b(?!\.)/, 'Name.Builtin' rule /(\b\w+)(=)/ do |_, var, eq, &out| out.call 'Name.Variable', var out.call 'Operator', eq end rule /[\[\]{}()=]/, 'Operator' rule /&&|\|\|/, 'Operator' # rule /\|\|/, 'Operator' rule /<<