cmder-powerline-prompt icon indicating copy to clipboard operation
cmder-powerline-prompt copied to clipboard

Add python virtual env support

Open davepwsmith opened this issue 6 years ago • 4 comments

I wanted to add a plugin for virtualenv support which followed the convention of adding in [ ] before the prompt. To do this I needed to insert after the newline and before the lambda - the easiest way of doing this was to split the closePrompt function in two, so that plugins could be registered between.

davepwsmith avatar May 31 '18 12:05 davepwsmith

why put it before the prompt instead of inside of the powerline?

mattdkerr avatar Jun 07 '18 20:06 mattdkerr

Just seemed like the done thing when I have had similar venv prompt indicators before... Would be easy too just to add it as a segment, I guess, but would need to somehow very clearly separate it from the other indicators (git etc.)

davepwsmith avatar Jun 07 '18 22:06 davepwsmith

A Python segment would look separate from the Git segment if used a distinct color. See the available colors in the table.
It can also has a symbol in front of it like the npm segment has an option for that.

If the Python needs to be shown before the Git segment, this can be done via the number passed to the register_filter function, like here. The lower the number, the earlier the segment.

I think a Python segment would also need to have an option to only show up when there's a py file in the folder. A user can choose to show the segment all the time as well.

AmrEldib avatar Jun 08 '18 20:06 AmrEldib

How about this then?

  • Virtual env displays after the folder and before the git in the powerline
  • There is an option (added to config sample) to show always or only when python files are present
  • It uses the same colours as the NPM prompt, which might not be ideal in some (rare?) situations where people are using python and node in the same directory. Blue and Yellow are the python colours but those are used by the git prompt.

davepwsmith avatar Jun 11 '18 09:06 davepwsmith