diff --git a/src/segments/python.go b/src/segments/python.go index 55873d19..5ff49e5c 100644 --- a/src/segments/python.go +++ b/src/segments/python.go @@ -135,8 +135,7 @@ func (p *Python) pyenvVersion() (string, error) { if err != nil { return "", err } - // Unset whatever loadContext thinks Venv should be - p.Venv = "" + // override virtualenv if pyenv set one parts := strings.Split(shortPath, string(filepath.Separator)) if len(parts) > 2 && p.canUseVenvName(parts[2]) { p.Venv = parts[2] diff --git a/src/segments/python_test.go b/src/segments/python_test.go index 7c4c7c2f..eb5fca64 100644 --- a/src/segments/python_test.go +++ b/src/segments/python_test.go @@ -70,9 +70,9 @@ func TestPythonTemplate(t *testing.T) { Case: "Pyenv virtual env version name", FetchVersion: true, VirtualEnvName: "demo", - Expected: "3.8.4", + Expected: "demo 3.8.4", PythonPath: "/home/user/.pyenv/shims/python", - Template: "{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}", + Template: "{{ .Venv }} {{ .Full }}", ResolveSymlink: ResolveSymlink{Path: "/home/user/.pyenv/versions/demo", Err: nil}, }, }