Pull requests

#55 Merged
Repository
Deleted repository
Branch
default (ae79ad7e75da)
Repository
birkenfeld/pygments-main pygments-main
Branch
default

Parse shell prompt when running inside a virtualenv

Author
  1. James Polley (Atlassian)
Reviewers
Description

I'm documenting some shell sessions where some of the commands are executed in the context of a virtual environment, which has modified the prompt.

The (virtualenv-name) prepended to the prompt caused those lines to not be detected as a prompt and thus not highlighted.

This small change to the relevant regex now catches those lines, and includes the (virtualenv-name) string as part of the Generic.Prompt

Running the tests (with STORE_OUTPUT = True) on the modified example.sh-session before and after the change gives this diff: {{{ @@ -50,4 +50,10 @@

(Token.Comment, u''), (Token.Text, u' '), (Token.Comment, u'# on etch\n'), - (Token.Generic.Output, u'(virtualenv-name)user@host:~$ ls -a\n')] + (Token.Generic.Prompt, u'(virtualenv-name)user@host:~$'), + (Token.Comment, u''), + (Token.Text, u' '), + (Token.Text, u'ls'), + (Token.Text, u' '), + (Token.Text, u'-a'), + (Token.Text, u'\n')] }}}

Comments (0)