Commits

James Polley (Atlassian) committed ae79ad7

Extend the parsing of Generic.Prompt when lexing a shell session to support the case where the shell is running inside a virtualenv

In this case, prompts look like this:

(virtualenv-name)user@host:~$

Comments (0)

Files changed (2)

pygments/lexers/shell.py

 
         for match in line_re.finditer(text):
             line = match.group()
-            m = re.match(r'^((?:|sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)?|\[\S+[@:]'
-                         r'[^\n]+\].+)[$#%])(.*\n?)', line)
+            m = re.match(r'^((?:\(\S+\))?(?:|sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)'
+                          r'?|\[\S+[@:][^\n]+\].+)[$#%])(.*\n?)' , line)
             if m:
                 # To support output lexers (say diff output), the output
                 # needs to be broken by prompts whenever the output lexer

tests/examplefiles/example.sh-session

 root@host:~#
 sh-3.1$ # on hardy
 sh$ # on etch
+(virtualenv-name)user@host:~$ ls -a
+