diff --git a/segment-virtualenv.go b/segment-virtualenv.go index 083c038..3baaec2 100644 --- a/segment-virtualenv.go +++ b/segment-virtualenv.go @@ -21,7 +21,14 @@ func segmentVirtualEnv(p *powerline) []pwl.Segment { if venv != "" { cfg, err := ini.Load(path.Join(venv, "pyvenv.cfg")) if err == nil { - env = cfg.Section("").Key("prompt").String() + // python >= 3.6 the venv module will not insert a prompt + // key unless the `--prompt` flag is passed to the module + // or if calling with the prompt arg EnvBuilder + // otherwise env evaluates to an empty string, per return + // of ini.File.Section.Key + if pyEnv := cfg.Section("").Key("prompt").String(); pyEnv != "" { + env = pyEnv + } } if env == "" { env = venv