b-ryan.powerline-shell/powerline_shell/segments/virtual_env.py
Karthik 21cfded8aa Real Virtual env name while using "pipenv".
pipenv is an officially recomended tool for managing python packages
dependencies.
In pipenv we have an option to create virtual env inside the project it
self.
The created virutal env name is .venv.

The normal bash display the name of the virual env as the parent folder
name.
Ex: new_shell/.venv then the virual env name displayed in base is
new_shell.

In powerline_shell the virtual env name is displayed as .venv.

This PR is a fix for displaying the parent folder as virtual env name.
2017-10-17 15:43:56 +05:30

19 lines
621 B
Python

import os
from ..utils import BasicSegment
class Segment(BasicSegment):
def add_to_powerline(self):
env = os.getenv('VIRTUAL_ENV') \
or os.getenv('CONDA_ENV_PATH') \
or os.getenv('CONDA_DEFAULT_ENV')
if os.getenv('VIRTUAL_ENV') \
and os.path.basename(env) == '.venv':
env = os.path.basename(os.path.dirname(env))
if not env:
return
env_name = os.path.basename(env)
bg = self.powerline.theme.VIRTUAL_ENV_BG
fg = self.powerline.theme.VIRTUAL_ENV_FG
self.powerline.append(" " + env_name + " ", fg, bg)