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 Jun 17, 2024
1 parent 3c6ebb4 commit ef5e672
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 @@ -17,12 +17,15 @@ func segmentVirtualEnv(p *powerline) []pwl.Segment {
env = strings.TrimSuffix(env, ") ")
}
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 ef5e672

Please sign in to comment.