File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -3,21 +3,29 @@ package main
3
3
import (
4
4
"os"
5
5
"path"
6
+ "strings"
6
7
7
8
"gopkg.in/ini.v1"
8
9
9
10
pwl "github.com/justjanne/powerline-go/powerline"
10
11
)
11
12
12
13
func segmentVirtualEnv (p * powerline ) []pwl.Segment {
13
- var env string
14
+ env := os .Getenv ("VIRTUAL_ENV_PROMPT" )
15
+ if strings .HasPrefix (env , "(" ) && strings .HasSuffix (env , ") " ) {
16
+ env = strings .TrimPrefix (env , "(" )
17
+ env = strings .TrimSuffix (env , ") " )
18
+ }
14
19
if env == "" {
15
- env , _ = os .LookupEnv ("VIRTUAL_ENV" )
16
- if env != "" {
17
- cfg , err := ini .Load (path .Join (env , "pyvenv.cfg" ))
20
+ venv , _ : = os .LookupEnv ("VIRTUAL_ENV" )
21
+ if venv != "" {
22
+ cfg , err := ini .Load (path .Join (venv , "pyvenv.cfg" ))
18
23
if err == nil {
19
24
env = cfg .Section ("" ).Key ("prompt" ).String ()
20
25
}
26
+ if env == "" {
27
+ env = venv
28
+ }
21
29
}
22
30
}
23
31
if env == "" {
You can’t perform that action at this time.
0 commit comments