1. Dag Odenhall
  2. pygments-main


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:


  • Participants
  • Parent commits 6a55708
  • Branches default

Comments (0)

Files changed (2)

File pygments/lexers/shell.py

View file
  • Ignore whitespace
         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

File tests/examplefiles/example.sh-session

View file
  • Ignore whitespace
 sh-3.1$ # on hardy
 sh$ # on etch
+(virtualenv-name)user@host:~$ ls -a