Skip to content

Commit

Permalink
feat(virtualenv): fall back to VIRTUAL_ENV dir if prompt is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Aug 13, 2023
1 parent a8a1891 commit a307d69
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions segment-virtualenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ func segmentVirtualEnv(p *powerline) []pwl.Segment {
env = env[1 : len(env)-2]
}
if env == "" {
env, _ = os.LookupEnv("VIRTUAL_ENV")
if env != "" {
cfg, err := ini.Load(path.Join(env, "pyvenv.cfg"))
venv, _ := os.LookupEnv("VIRTUAL_ENV")
if venv != "" {
cfg, err := ini.Load(path.Join(venv, "pyvenv.cfg"))
if err == nil {
env = cfg.Section("").Key("prompt").String()
}
if env == "" {
env = venv
}
}
}
if env == "" {
Expand Down

0 comments on commit a307d69

Please sign in to comment.