Skip to content

Commit

Permalink
Merge pull request #284 from Belphegor/master
Browse files Browse the repository at this point in the history
Use altermative prompt from python venv
  • Loading branch information
justjanne authored Apr 21, 2022
2 parents e952b09 + a6d5c7a commit a7e4485
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ powerline-go
.glide/

/.idea/
~

.vscode/
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ require (
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221
golang.org/x/text v0.3.4
gopkg.in/ini.v1 v1.66.4
gopkg.in/yaml.v2 v2.4.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IV
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4=
gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down
8 changes: 8 additions & 0 deletions segment-virtualenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ import (
"os"
"path"

"gopkg.in/ini.v1"

pwl "github.com/justjanne/powerline-go/powerline"
)

func segmentVirtualEnv(p *powerline) []pwl.Segment {
var env string
if env == "" {
env, _ = os.LookupEnv("VIRTUAL_ENV")
if env != "" {
cfg, err := ini.Load(path.Join(env, "pyvenv.cfg"))
if err == nil {
env = cfg.Section("").Key("prompt").String()
}
}
}
if env == "" {
env, _ = os.LookupEnv("CONDA_ENV_PATH")
Expand Down

0 comments on commit a7e4485

Please sign in to comment.