feat(python): virtual env in template

This commit is contained in:
Jan De Dobbeleer 2021-12-04 11:56:55 +01:00 committed by Jan De Dobbeleer
parent f495a7093a
commit 29afb86e61
34 changed files with 233 additions and 159 deletions

View file

@ -27,7 +27,7 @@ Supports conda, virtualenv and pyenv.
## Properties ## Properties
- home_enabled: `boolean` - display the segment in the HOME folder or not - defaults to `false` - home_enabled: `boolean` - display the segment in the HOME folder or not - defaults to `false`
- display_virtual_env: `boolean` - show the name of the virtualenv or not - defaults to `true` - fetch_virtual_env: `boolean` - fetch the name of the virtualenv or not - defaults to `true`
- display_default: `boolean` - show the name of the virtualenv when it's default (`system`, `base`) - display_default: `boolean` - show the name of the virtualenv when it's default (`system`, `base`)
or not - defaults to `true` or not - defaults to `true`
- display_version: `boolean` - display the python version - defaults to `true` - display_version: `boolean` - display the python version - defaults to `true`

View file

@ -23,8 +23,8 @@ const (
ExcludeFolders Property = "exclude_folders" ExcludeFolders Property = "exclude_folders"
// IgnoreFolders duplicate of ExcludeFolders // IgnoreFolders duplicate of ExcludeFolders
IgnoreFolders Property = "ignore_folders" IgnoreFolders Property = "ignore_folders"
// DisplayVersion show the version number or not // FetchVersion fetch the version number or not
DisplayVersion Property = "display_version" FetchVersion Property = "fetch_version"
// AlwaysEnabled decides whether or not to always display the info // AlwaysEnabled decides whether or not to always display the info
AlwaysEnabled Property = "always_enabled" AlwaysEnabled Property = "always_enabled"
// SegmentTemplate is the template to use to render the information // SegmentTemplate is the template to use to render the information

View file

@ -17,12 +17,12 @@ const (
// Properties // Properties
func (p properties) getOneOfBool(property, legacyProperty Property) bool { func (p properties) getOneOfBool(property, legacyProperty Property, defaultValue bool) bool {
_, found := p[legacyProperty] _, found := p[legacyProperty]
if found { if found {
return p.getBool(legacyProperty, false) return p.getBool(legacyProperty, defaultValue)
} }
return p.getBool(property, false) return p.getBool(property, defaultValue)
} }
func (p properties) hasOneOf(properties ...Property) bool { func (p properties) hasOneOf(properties ...Property) bool {
@ -306,3 +306,81 @@ func (s *session) getFormattedText() string {
} }
return fmt.Sprintf("%s%s%s%s", sshIcon, s.UserName, separator, s.ComputerName) return fmt.Sprintf("%s%s%s%s", sshIcon, s.UserName, separator, s.ComputerName)
} }
// Language
const (
// DisplayVersion show the version number or not
DisplayVersion Property = "display_version"
)
func (l *language) string() string {
if !l.props.getBool(DisplayVersion, true) {
return ""
}
err := l.setVersion()
if err != nil {
l.Error = err.Error()
}
displayError := l.props.getBool(DisplayError, true)
if err != nil && displayError {
return err.Error()
}
if err != nil {
return ""
}
segmentTemplate := l.props.getString(SegmentTemplate, "{{ .Full }}")
template := &textTemplate{
Template: segmentTemplate,
Context: l.version,
Env: l.env,
}
text, err := template.render()
if err != nil {
return err.Error()
}
if l.props.getBool(EnableHyperlink, false) {
versionURLTemplate := l.props.getString(VersionURLTemplate, "")
// backward compatibility
if versionURLTemplate == "" {
text = l.buildVersionURL(text)
} else {
template := &textTemplate{
Template: versionURLTemplate,
Context: l.version,
Env: l.env,
}
url, err := template.render()
if err != nil {
return err.Error()
}
text = url
}
}
if l.props.getBool(EnableVersionMismatch, false) {
l.setVersionFileMismatch()
}
return text
}
// Python
const (
// DisplayVirtualEnv shows or hides the virtual env
DisplayVirtualEnv Property = "display_virtual_env"
)
func (p *python) legacyString() string {
if p.Venv == "" {
return p.language.string()
}
version := p.language.string()
if version == "" {
return p.Venv
}
return fmt.Sprintf("%s %s", p.Venv, version)
}

View file

@ -596,3 +596,50 @@ func TestPropertySessionSegment(t *testing.T) {
} }
} }
} }
// Python
func TestPythonVirtualEnv(t *testing.T) {
cases := []struct {
Case string
Expected string
ExpectedDisabled bool
VirtualEnvName string
CondaEnvName string
CondaDefaultEnvName string
PyEnvName string
DisplayVersion bool
DisplayDefault bool
}{
{Case: "VENV", Expected: "VENV", VirtualEnvName: "VENV"},
{Case: "CONDA", Expected: "CONDA", CondaEnvName: "CONDA"},
{Case: "CONDA default", Expected: "CONDA", CondaDefaultEnvName: "CONDA"},
{Case: "Display Base", Expected: "base", CondaDefaultEnvName: "base", DisplayDefault: true},
{Case: "Hide base", Expected: "", CondaDefaultEnvName: "base", ExpectedDisabled: true},
{Case: "PYENV", Expected: "PYENV", PyEnvName: "PYENV"},
{Case: "PYENV Version", Expected: "PYENV 3.8.4", PyEnvName: "PYENV", DisplayVersion: true},
}
for _, tc := range cases {
env := new(MockedEnvironment)
env.On("hasCommand", "python").Return(true)
env.On("runCommand", "python", []string{"--version"}).Return("Python 3.8.4", nil)
env.On("hasFiles", "*.py").Return(true)
env.On("getenv", "VIRTUAL_ENV").Return(tc.VirtualEnvName)
env.On("getenv", "CONDA_ENV_PATH").Return(tc.CondaEnvName)
env.On("getenv", "CONDA_DEFAULT_ENV").Return(tc.CondaDefaultEnvName)
env.On("getenv", "PYENV_VERSION").Return(tc.PyEnvName)
env.On("getPathSeperator", nil).Return("")
env.On("getcwd", nil).Return("/usr/home/project")
env.On("homeDir", nil).Return("/usr/home")
var props properties = map[Property]interface{}{
DisplayVersion: tc.DisplayVersion,
DisplayVirtualEnv: true,
DisplayDefault: tc.DisplayDefault,
}
python := &python{}
python.init(props, env)
assert.Equal(t, !tc.ExpectedDisabled, python.enabled(), tc.Case)
assert.Equal(t, tc.Expected, python.string(), tc.Case)
}
}

View file

@ -184,20 +184,20 @@ func (g *git) shouldIgnoreRootRepository(rootDir string) bool {
func (g *git) string() string { func (g *git) string() string {
statusColorsEnabled := g.props.getBool(StatusColorsEnabled, false) statusColorsEnabled := g.props.getBool(StatusColorsEnabled, false)
displayStatus := g.props.getOneOfBool(FetchStatus, DisplayStatus) displayStatus := g.props.getOneOfBool(FetchStatus, DisplayStatus, false)
if !displayStatus { if !displayStatus {
g.HEAD = g.getPrettyHEADName() g.HEAD = g.getPrettyHEADName()
} }
if displayStatus || statusColorsEnabled { if displayStatus || statusColorsEnabled {
g.setGitStatus() g.setGitStatus()
} }
if g.Upstream != "" && g.props.getOneOfBool(FetchUpstreamIcon, DisplayUpstreamIcon) { if g.Upstream != "" && g.props.getOneOfBool(FetchUpstreamIcon, DisplayUpstreamIcon, false) {
g.UpstreamIcon = g.getUpstreamIcon() g.UpstreamIcon = g.getUpstreamIcon()
} }
if g.props.getOneOfBool(FetchStashCount, DisplayStashCount) { if g.props.getOneOfBool(FetchStashCount, DisplayStashCount, false) {
g.StashCount = g.getStashContext() g.StashCount = g.getStashContext()
} }
if g.props.getOneOfBool(FetchWorktreeCount, DisplayWorktreeCount) { if g.props.getOneOfBool(FetchWorktreeCount, DisplayWorktreeCount, false) {
g.WorktreeCount = g.getWorktreeContext() g.WorktreeCount = g.getWorktreeContext()
} }
// use template if available // use template if available

View file

@ -84,25 +84,17 @@ const (
LanguageExtensions Property = "extensions" LanguageExtensions Property = "extensions"
) )
func (l *language) string() string { func (l *language) renderTemplate(segmentTemplate string, context SegmentWriter) string {
if !l.props.getBool(DisplayVersion, true) { if l.props.getBool(FetchVersion, true) {
return ""
}
err := l.setVersion() err := l.setVersion()
l.Error = err.Error()
displayError := l.props.getBool(DisplayError, true)
if err != nil && displayError {
return err.Error()
}
if err != nil { if err != nil {
return "" l.Error = err.Error()
}
} }
segmentTemplate := l.props.getString(SegmentTemplate, "{{ .Full }}")
template := &textTemplate{ template := &textTemplate{
Template: segmentTemplate, Template: segmentTemplate,
Context: l.version, Context: context,
Env: l.env, Env: l.env,
} }
text, err := template.render() text, err := template.render()
@ -110,28 +102,23 @@ func (l *language) string() string {
return err.Error() return err.Error()
} }
if l.props.getBool(EnableHyperlink, false) { if !l.props.getBool(EnableHyperlink, false) {
return text
}
versionURLTemplate := l.props.getString(VersionURLTemplate, "") versionURLTemplate := l.props.getString(VersionURLTemplate, "")
// backward compatibility // backward compatibility
if versionURLTemplate == "" { if versionURLTemplate == "" {
text = l.buildVersionURL(text) return l.buildVersionURL(text)
} else { }
template := &textTemplate{ template = &textTemplate{
Template: versionURLTemplate, Template: versionURLTemplate,
Context: l.version, Context: l.version,
Env: l.env, Env: l.env,
} }
url, err := template.render() text, err = template.render()
if err != nil { if err != nil {
return err.Error() return err.Error()
} }
text = url
}
}
if l.props.getBool(EnableVersionMismatch, false) {
l.setVersionFileMismatch()
}
return text return text
} }

View file

@ -1,7 +1,5 @@
package main package main
import "fmt"
type python struct { type python struct {
language language
@ -9,19 +7,16 @@ type python struct {
} }
const ( const (
// DisplayVirtualEnv shows or hides the virtual env // FetchVirtualEnv fetches the virtual env
DisplayVirtualEnv Property = "display_virtual_env" FetchVirtualEnv Property = "fetch_virtual_env"
) )
func (p *python) string() string { func (p *python) string() string {
if p.Venv == "" { segmentTemplate := p.language.props.getString(SegmentTemplate, "")
return p.language.string() if len(segmentTemplate) == 0 {
return p.legacyString()
} }
version := p.language.string() return p.language.renderTemplate(segmentTemplate, p)
if version == "" {
return p.Venv
}
return fmt.Sprintf("%s %s", p.Venv, version)
} }
func (p *python) init(props properties, env environmentInfo) { func (p *python) init(props properties, env environmentInfo) {
@ -54,7 +49,7 @@ func (p *python) enabled() bool {
} }
func (p *python) loadContext() { func (p *python) loadContext() {
if !p.language.props.getBool(DisplayVirtualEnv, true) { if !p.language.props.getOneOfBool(DisplayVirtualEnv, FetchVirtualEnv, true) {
return return
} }
venvVars := []string{ venvVars := []string{

View file

@ -6,25 +6,38 @@ import (
"github.com/alecthomas/assert" "github.com/alecthomas/assert"
) )
func TestPythonVirtualEnv(t *testing.T) { func TestPythonTemplate(t *testing.T) {
cases := []struct { cases := []struct {
Case string Case string
Expected string Expected string
ExpectedDisabled bool ExpectedDisabled bool
Template string
VirtualEnvName string VirtualEnvName string
CondaEnvName string FetchVersion bool
CondaDefaultEnvName string
PyEnvName string
DisplayVersion bool
DisplayDefault bool
}{ }{
{Case: "VENV", Expected: "VENV", VirtualEnvName: "VENV"}, {Case: "No virtual env present", FetchVersion: true, Expected: "3.8.4", Template: "{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}"},
{Case: "CONDA", Expected: "CONDA", CondaEnvName: "CONDA"}, {Case: "Virtual env present", FetchVersion: true, Expected: "VENV 3.8.4", VirtualEnvName: "VENV", Template: "{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}"},
{Case: "CONDA default", Expected: "CONDA", CondaDefaultEnvName: "CONDA"}, {
{Case: "Display Base", Expected: "base", CondaDefaultEnvName: "base", DisplayDefault: true}, Case: "Virtual env major and minor dot",
{Case: "Hide base", Expected: "", CondaDefaultEnvName: "base", ExpectedDisabled: true}, FetchVersion: true,
{Case: "PYENV", Expected: "PYENV", PyEnvName: "PYENV"}, Expected: "VENV 3.8",
{Case: "PYENV Version", Expected: "PYENV 3.8.4", PyEnvName: "PYENV", DisplayVersion: true}, VirtualEnvName: "VENV",
Template: "{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Major }}.{{ .Minor }}",
},
{
Case: "Virtual env hide on default",
FetchVersion: true,
Expected: "3.8",
VirtualEnvName: "default",
Template: "{{ if ne .Venv \"default\" }}{{ .Venv }} {{ end }}{{ .Major }}.{{ .Minor }}",
},
{
Case: "Virtual env show non default",
FetchVersion: true,
Expected: "billy 3.8",
VirtualEnvName: "billy",
Template: "{{ if ne .Venv \"default\" }}{{ .Venv }} {{ end }}{{ .Major }}.{{ .Minor }}",
},
} }
for _, tc := range cases { for _, tc := range cases {
@ -33,16 +46,16 @@ func TestPythonVirtualEnv(t *testing.T) {
env.On("runCommand", "python", []string{"--version"}).Return("Python 3.8.4", nil) env.On("runCommand", "python", []string{"--version"}).Return("Python 3.8.4", nil)
env.On("hasFiles", "*.py").Return(true) env.On("hasFiles", "*.py").Return(true)
env.On("getenv", "VIRTUAL_ENV").Return(tc.VirtualEnvName) env.On("getenv", "VIRTUAL_ENV").Return(tc.VirtualEnvName)
env.On("getenv", "CONDA_ENV_PATH").Return(tc.CondaEnvName) env.On("getenv", "CONDA_ENV_PATH").Return(tc.VirtualEnvName)
env.On("getenv", "CONDA_DEFAULT_ENV").Return(tc.CondaDefaultEnvName) env.On("getenv", "CONDA_DEFAULT_ENV").Return(tc.VirtualEnvName)
env.On("getenv", "PYENV_VERSION").Return(tc.PyEnvName) env.On("getenv", "PYENV_VERSION").Return(tc.VirtualEnvName)
env.On("getPathSeperator", nil).Return("") env.On("getPathSeperator", nil).Return("")
env.On("getcwd", nil).Return("/usr/home/project") env.On("getcwd", nil).Return("/usr/home/project")
env.On("homeDir", nil).Return("/usr/home") env.On("homeDir", nil).Return("/usr/home")
var props properties = map[Property]interface{}{ var props properties = map[Property]interface{}{
DisplayVersion: tc.DisplayVersion, FetchVersion: tc.FetchVersion,
DisplayVirtualEnv: true, SegmentTemplate: tc.Template,
DisplayDefault: tc.DisplayDefault, DisplayMode: DisplayModeAlways,
} }
python := &python{} python := &python{}
python.init(props, env) python.init(props, env)

View file

@ -122,9 +122,9 @@
"background": "p:python", "background": "p:python",
"properties": { "properties": {
"prefix": " \uE235 ", "prefix": " \uE235 ",
"display_version": true,
"display_mode": "files", "display_mode": "files",
"display_virtual_env": false "fetch_virtual_env": false,
"template": "{{ .Full }}"
} }
}, },
{ {

View file

@ -91,9 +91,9 @@
"background": "#FFDE57", "background": "#FFDE57",
"properties": { "properties": {
"prefix": " \uE235 ", "prefix": " \uE235 ",
"display_version": true,
"display_mode": "files", "display_mode": "files",
"display_virtual_env": false "fetch_virtual_env": false,
"template": "{{ .Full }}"
} }
}, },
{ {

View file

@ -288,7 +288,6 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"properties": { "properties": {
"prefix": " \uf5ef ", "prefix": " \uf5ef ",
"postfix": " ",
"time_format": "_2,15:04" "time_format": "_2,15:04"
} }
} }

View file

@ -14,7 +14,6 @@
"foreground": "#fff", "foreground": "#fff",
"properties": { "properties": {
"prefix": "", "prefix": "",
"postfix": " ",
"template": "{{ .UserName }}" "template": "{{ .UserName }}"
} }
}, },
@ -26,9 +25,7 @@
"background": "green", "background": "green",
"foreground": "#fff", "foreground": "#fff",
"properties": { "properties": {
"style": "folder", "style": "folder"
"prefix": " ",
"postfix": " "
} }
}, },
{ {
@ -53,9 +50,7 @@
"foreground": "#fff", "foreground": "#fff",
"background": "lightMagenta", "background": "lightMagenta",
"properties": { "properties": {
"time_format": "15:04", "time_format": "15:04"
"prefix": " ",
"postfix": " "
} }
} }
] ]

View file

@ -36,8 +36,7 @@
"folder_icon": "\uF115", "folder_icon": "\uF115",
"folder_separator_icon": " \uE0B1 ", "folder_separator_icon": " \uE0B1 ",
"style": "full", "style": "full",
"prefix": "<transparent>\uE0B0</> ", "prefix": "<transparent>\uE0B0</> "
"postfix": " "
} }
}, },
{ {
@ -47,7 +46,6 @@
"background": "#007ACC", "background": "#007ACC",
"properties": { "properties": {
"prefix": "<#ffffff>\uE0B1</> ", "prefix": "<#ffffff>\uE0B1</> ",
"postfix": " ",
"template": "{{ .HEAD }}" "template": "{{ .HEAD }}"
} }
}, },

View file

@ -39,8 +39,7 @@
"foreground": "#193549", "foreground": "#193549",
"background": "#4caf50", "background": "#4caf50",
"properties": { "properties": {
"time_format": "2006-01-02 15:04:05", "time_format": "2006-01-02 15:04:05"
"prefix": " "
} }
}, },

View file

@ -84,8 +84,7 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#83769c", "background": "#83769c",
"properties": { "properties": {
"always_enabled": true, "always_enabled": true
"prefix": " "
} }
}, },
{ {
@ -96,7 +95,6 @@
"foreground": "#FFD700", "foreground": "#FFD700",
"background": "#86BBD8", "background": "#86BBD8",
"properties": { "properties": {
"prefix": " ",
"postfix": "", "postfix": "",
"root_icon": "⚡" "root_icon": "⚡"
} }
@ -118,11 +116,7 @@
"trailing_diamond": "\uE0B4", "trailing_diamond": "\uE0B4",
"invert_powerline": true, "invert_powerline": true,
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#33658A", "background": "#33658A"
"properties": {
"prefix": " ",
"postfix": " "
}
} }
] ]
}, },

View file

@ -16,7 +16,6 @@
"foreground": "#fff", "foreground": "#fff",
"background": "#003543", "background": "#003543",
"properties": { "properties": {
"prefix": " ",
"windows": "\uF179", "windows": "\uF179",
"postfix": "" "postfix": ""
} }
@ -105,9 +104,9 @@
"background": "#0087D8", "background": "#0087D8",
"properties": { "properties": {
"prefix": " \uE235 ", "prefix": " \uE235 ",
"display_version": false,
"display_mode": "context", "display_mode": "context",
"display_virtual_env": true "fetch_virtual_env": true,
"template": "{{ .Venv }}"
} }
}, },
{ {

View file

@ -91,9 +91,9 @@
"background": "#FFDE57", "background": "#FFDE57",
"properties": { "properties": {
"prefix": " \uE235 ", "prefix": " \uE235 ",
"display_version": true,
"display_mode": "files", "display_mode": "files",
"display_virtual_env": false "fetch_virtual_env": false,
"template": "{{ .Full }}"
} }
}, },
{ {

View file

@ -16,7 +16,6 @@
"leading_diamond": "\uE0B6", "leading_diamond": "\uE0B6",
"trailing_diamond": "\uE0B0", "trailing_diamond": "\uE0B0",
"properties": { "properties": {
"prefix": " ",
"wsl": "", "wsl": "",
"wsl_separator": "" "wsl_separator": ""
}, },
@ -59,7 +58,6 @@
"fetch_stash_count": true, "fetch_stash_count": true,
"fetch_status": true, "fetch_status": true,
"fetch_upstream_icon": true, "fetch_upstream_icon": true,
"prefix": " ",
"template": "{{ .UpstreamIcon }}{{ .HEAD }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }}" "template": "{{ .UpstreamIcon }}{{ .HEAD }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }}"
}, },
"style": "powerline", "style": "powerline",

View file

@ -59,7 +59,6 @@
"style": "mixed", "style": "mixed",
"home_icon": "\uf7dd ", "home_icon": "\uf7dd ",
"prefix": "", "prefix": "",
"postfix": " ",
"enable_hyperlink": true "enable_hyperlink": true
} }
}, },

View file

@ -41,7 +41,6 @@
"foreground": "#DCB977", "foreground": "#DCB977",
"properties": { "properties": {
"template": "\uF119", "template": "\uF119",
"prefix": " ",
"postfix": "" "postfix": ""
} }
}, },

View file

@ -13,7 +13,6 @@
"foreground": "#0077c2", "foreground": "#0077c2",
"background": "#fbfbfb", "background": "#fbfbfb",
"properties": { "properties": {
"postfix": " ",
"macos": "\uEF179", "macos": "\uEF179",
"windows": "\uF17A", "windows": "\uF17A",
"linux": "\uF17C", "linux": "\uF17C",
@ -87,7 +86,6 @@
"style": "plain", "style": "plain",
"foreground": "#FFD54F", "foreground": "#FFD54F",
"properties": { "properties": {
"prefix": " ",
"text": "{{if .Root}}#{{else}}${{end}}", "text": "{{if .Root}}#{{else}}${{end}}",
"postfix": "" "postfix": ""
} }

View file

@ -69,9 +69,9 @@
"foreground": "#4584b6", "foreground": "#4584b6",
"properties": { "properties": {
"prefix": "| \uE235 ", "prefix": "| \uE235 ",
"display_version": false,
"display_mode": "context", "display_mode": "context",
"display_virtual_env": true "fetch_virtual_env": true,
"template": "{{ .Venv }}"
} }
}, },
{ {

View file

@ -82,7 +82,6 @@
"foreground": "#d6deeb", "foreground": "#d6deeb",
"background": "#575656", "background": "#575656",
"properties": { "properties": {
"postfix": " ",
"threshold": 0, "threshold": 0,
"style": "roundrock" "style": "roundrock"
} }

View file

@ -39,8 +39,7 @@
"style": "plain", "style": "plain",
"foreground": "#DCB977", "foreground": "#DCB977",
"properties": { "properties": {
"template": "\uF119", "template": "\uF119"
"prefix": " "
} }
} }
] ]

View file

@ -14,7 +14,6 @@
"foreground": "red", "foreground": "red",
"properties": { "properties": {
"prefix": "", "prefix": "",
"postfix": " ",
"root_icon": "\uF0E7" "root_icon": "\uF0E7"
} }
}, },

View file

@ -26,8 +26,7 @@
"foreground": "#26C6DA", "foreground": "#26C6DA",
"background": "#546E7A", "background": "#546E7A",
"properties": { "properties": {
"style": "full", "style": "full"
"postfix": " "
} }
}, },
{ {

View file

@ -30,8 +30,7 @@
"background": "#0000ff", "background": "#0000ff",
"powerline_symbol": "\uE0B4", "powerline_symbol": "\uE0B4",
"properties": { "properties": {
"style": "full", "style": "full"
"postfix": " "
} }
}, },
{ {
@ -41,7 +40,6 @@
"background": "#D4E157", "background": "#D4E157",
"powerline_symbol": "\uE0B4", "powerline_symbol": "\uE0B4",
"properties": { "properties": {
"prefix": " ",
"template": "{{ .HEAD }}" "template": "{{ .HEAD }}"
} }
} }

View file

@ -95,9 +95,9 @@
"background": "#FFDE57", "background": "#FFDE57",
"properties": { "properties": {
"postfix": " \uE235 ", "postfix": " \uE235 ",
"display_version": true,
"display_mode": "files", "display_mode": "files",
"display_virtual_env": false "fetch_virtual_env": false,
"template": "{{ .Full }}"
} }
}, },
{ {
@ -172,7 +172,6 @@
"background": "#000000", "background": "#000000",
"background_templates": ["{{ if gt .Code 0 }}#cc2222{{ end }}"], "background_templates": ["{{ if gt .Code 0 }}#cc2222{{ end }}"],
"properties": { "properties": {
"prefix": " ",
"always_enabled": true, "always_enabled": true,
"template": "{{ if gt .Code 0 }}{{ .Text }}{{ else }}✔{{ end }}" "template": "{{ if gt .Code 0 }}{{ .Text }}{{ else }}✔{{ end }}"
} }

View file

@ -40,7 +40,6 @@
"foreground": "#BF616A", "foreground": "#BF616A",
"properties": { "properties": {
"template": "\u2717", "template": "\u2717",
"prefix": " ",
"postfix": "" "postfix": ""
} }
} }

View file

@ -18,9 +18,7 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"properties": { "properties": {
"wsl": "", "wsl": "",
"wsl_separator": "", "wsl_separator": ""
"prefix": " ",
"postfix": " "
} }
}, },
{ {
@ -42,8 +40,7 @@
"max_depth": 2, "max_depth": 2,
"folder_icon": "\uF115", "folder_icon": "\uF115",
"folder_separator_icon": " \uE0B1 ", "folder_separator_icon": " \uE0B1 ",
"style": "agnoster_short", "style": "agnoster_short"
"postfix": " "
} }
}, },
{ {

View file

@ -18,9 +18,7 @@
"foreground": "#EF7D00", "foreground": "#EF7D00",
"properties": { "properties": {
"wsl": "", "wsl": "",
"wsl_separator": "", "wsl_separator": ""
"prefix": " ",
"postfix": " "
} }
}, },
{ {

View file

@ -1240,19 +1240,10 @@
"properties": { "properties": {
"properties": { "properties": {
"properties": { "properties": {
"display_version": { "fetch_virtual_env": {
"$ref": "#/definitions/display_version"
},
"display_default": {
"type": "boolean", "type": "boolean",
"title": "Display Default Env", "title": "Fetch Virtual Env",
"description": "Show the name of the virtualenv when it's default (`system`, `base`)", "description": "Fetch the name of the virtualenv or not",
"default": true
},
"display_virtual_env": {
"type": "boolean",
"title": "Display Virtual Env",
"description": "Show the name of the virtualenv or not",
"default": true "default": true
}, },
"display_mode": { "display_mode": {
@ -1263,6 +1254,9 @@
}, },
"enable_hyperlink": { "enable_hyperlink": {
"$ref": "#/definitions/enable_hyperlink" "$ref": "#/definitions/enable_hyperlink"
},
"template": {
"$ref": "#/definitions/template"
} }
} }
} }

View file

@ -17,7 +17,6 @@
"foreground": "#fff", "foreground": "#fff",
"background": "#003543", "background": "#003543",
"properties": { "properties": {
"prefix": " ",
"windows": "\uE62A ", "windows": "\uE62A ",
"postfix": "" "postfix": ""
} }

View file

@ -46,7 +46,6 @@
"foreground": "#68a063", "foreground": "#68a063",
"properties": { "properties": {
"display_version": true, "display_version": true,
"prefix": " ",
"postfix": "", "postfix": "",
"display_mode": "files", "display_mode": "files",
"display_package_manager": true, "display_package_manager": true,
@ -61,7 +60,6 @@
"properties": { "properties": {
"display_version": true, "display_version": true,
"display_mode": "files", "display_mode": "files",
"prefix": " ",
"postfix": "" "postfix": ""
} }
}, },
@ -71,7 +69,6 @@
"foreground": "#DE3F24", "foreground": "#DE3F24",
"properties": { "properties": {
"display_version": true, "display_version": true,
"prefix": " ",
"postfix": "", "postfix": "",
"display_mode": "files" "display_mode": "files"
} }
@ -81,11 +78,10 @@
"style": "plain", "style": "plain",
"foreground": "#FED142", "foreground": "#FED142",
"properties": { "properties": {
"display_virtual_env": false, "fetch_virtual_env": false,
"display_version": true,
"prefix": " ",
"postfix": "", "postfix": "",
"display_mode": "context" "display_mode": "context",
"template": "{{ .Full }}"
} }
}, },
{ {