module Rouge module Lexers class ShellLexer < RegexLexer tag 'shell' aliases 'bash', 'zsh', 'ksh', 'sh' extensions 'sh', 'bash', 'zsh', 'ksh' KEYWORDS = %w( if fi else while do done for then return function select continue until esac elif in ).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('|') state :basic do rule /#.*\n/, 'Comment' rule /\b(#{KEYWORDS})\s*\b/, 'Keyword' rule /\bcase\b/, 'Keyword', :case rule /\b(#{BUILTINS})\s*\b(?!\.)/, 'Name.Builtin' rule /(\b\w+)(=)/ do |m| group 'Name.Variable' group 'Operator' end rule /[\[\]{}()=]/, 'Operator' rule /&&|\|\|/, 'Operator' # rule /\|\|/, 'Operator' rule /<<