55 (r'\$[a-zA-Z_]\w*', Name.Variable), # user variable |
55 (r'\$[a-zA-Z_]\w*', Name.Variable), # user variable |
56 (r'\$(?:\d+|[#$?!_*@-])', Name.Variable), # builtin |
56 (r'\$(?:\d+|[#$?!_*@-])', Name.Variable), # builtin |
57 (r'\$', Text), |
57 (r'\$', Text), |
58 ], |
58 ], |
59 'basic': [ |
59 'basic': [ |
60 (r'\b(if|fi|else|while|do|done|for|then|return|function|case|' |
60 (r'\b(if|fi|else|while|in|do|done|for|then|return|function|case|' |
61 r'select|continue|until|esac|elif)(\s*)\b', |
61 r'select|continue|until|esac|elif)(\s*)\b', |
62 bygroups(Keyword, Text)), |
62 bygroups(Keyword, Text)), |
63 (r'\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|' |
63 (r'\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|' |
64 r'complete|declare|dirs|disown|echo|enable|eval|exec|exit|' |
64 r'complete|declare|dirs|disown|echo|enable|eval|exec|exit|' |
65 r'export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|' |
65 r'export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|' |
147 elif token is Comment.Single and 'SBATCH' in value: |
147 elif token is Comment.Single and 'SBATCH' in value: |
148 yield index, Keyword.Pseudo, value |
148 yield index, Keyword.Pseudo, value |
149 else: |
149 else: |
150 yield index, token, value |
150 yield index, token, value |
151 |
151 |
|
152 |
152 class ShellSessionBaseLexer(Lexer): |
153 class ShellSessionBaseLexer(Lexer): |
153 """ |
154 """ |
154 Base lexer for simplistic shell sessions. |
155 Base lexer for shell sessions. |
155 |
156 |
156 .. versionadded:: 2.1 |
157 .. versionadded:: 2.1 |
157 """ |
158 """ |
158 |
159 |
159 _venv = re.compile(r'^(\([^)]*\))(\s*)') |
160 _venv = re.compile(r'^(\([^)]*\))(\s*)') |
215 yield pos+i, t, v |
216 yield pos+i, t, v |
216 |
217 |
217 |
218 |
218 class BashSessionLexer(ShellSessionBaseLexer): |
219 class BashSessionLexer(ShellSessionBaseLexer): |
219 """ |
220 """ |
220 Lexer for simplistic shell sessions. |
221 Lexer for Bash shell sessions, i.e. command lines, including a |
|
222 prompt, interspersed with output. |
221 |
223 |
222 .. versionadded:: 1.1 |
224 .. versionadded:: 1.1 |
223 """ |
225 """ |
224 |
226 |
225 name = 'Bash Session' |
227 name = 'Bash Session' |
228 mimetypes = ['application/x-shell-session', 'application/x-sh-session'] |
230 mimetypes = ['application/x-shell-session', 'application/x-sh-session'] |
229 |
231 |
230 _innerLexerCls = BashLexer |
232 _innerLexerCls = BashLexer |
231 _ps1rgx = re.compile( |
233 _ps1rgx = re.compile( |
232 r'^((?:(?:\[.*?\])|(?:\(\S+\))?(?:| |sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)' \ |
234 r'^((?:(?:\[.*?\])|(?:\(\S+\))?(?:| |sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)' \ |
233 r'?|\[\S+[@:][^\n]+\].+))\s*[$#%])(.*\n?)') |
235 r'?|\[\S+[@:][^\n]+\].+))\s*[$#%]\s*)(.*\n?)') |
234 _ps2 = '>' |
236 _ps2 = '>' |
235 |
237 |
236 |
238 |
237 class BatchLexer(RegexLexer): |
239 class BatchLexer(RegexLexer): |
238 """ |
240 """ |
544 } |
546 } |
545 |
547 |
546 |
548 |
547 class MSDOSSessionLexer(ShellSessionBaseLexer): |
549 class MSDOSSessionLexer(ShellSessionBaseLexer): |
548 """ |
550 """ |
549 Lexer for simplistic MSDOS sessions. |
551 Lexer for MS DOS shell sessions, i.e. command lines, including a |
|
552 prompt, interspersed with output. |
550 |
553 |
551 .. versionadded:: 2.1 |
554 .. versionadded:: 2.1 |
552 """ |
555 """ |
553 |
556 |
554 name = 'MSDOS Session' |
557 name = 'MSDOS Session' |
629 } |
632 } |
630 |
633 |
631 |
634 |
632 class TcshSessionLexer(ShellSessionBaseLexer): |
635 class TcshSessionLexer(ShellSessionBaseLexer): |
633 """ |
636 """ |
634 Lexer for Tcsh sessions. |
637 Lexer for Tcsh sessions, i.e. command lines, including a |
|
638 prompt, interspersed with output. |
635 |
639 |
636 .. versionadded:: 2.1 |
640 .. versionadded:: 2.1 |
637 """ |
641 """ |
638 |
642 |
639 name = 'Tcsh Session' |
643 name = 'Tcsh Session' |
760 } |
764 } |
761 |
765 |
762 |
766 |
763 class PowerShellSessionLexer(ShellSessionBaseLexer): |
767 class PowerShellSessionLexer(ShellSessionBaseLexer): |
764 """ |
768 """ |
765 Lexer for simplistic Windows PowerShell sessions. |
769 Lexer for PowerShell sessions, i.e. command lines, including a |
|
770 prompt, interspersed with output. |
766 |
771 |
767 .. versionadded:: 2.1 |
772 .. versionadded:: 2.1 |
768 """ |
773 """ |
769 |
774 |
770 name = 'PowerShell Session' |
775 name = 'PowerShell Session' |