feat(exit): implement pipestatus

BREAKING CHANGE: exit segment is now called status segment.

The exit keyword is now deprecated and will be removed in a future
release. Please use the status keyword instead:

```diff
"segments": {
    {
-     "type": "exit"
+     "type": "status"
    }
}
```

Additionally, the status segment configuration has changed to support
$PIPESTATUS. You can include a status template to customize the
rendering of each individual status code (supported in fish, zsh and
bash).

```json
"segments": {
    {
        "type": "status",
        "properties": {
            "status_template": "{{ if gt .Code 0 }}\uf071{{ else }}\uf00c{{ end }}",
            "status_separator": " "
        }
    }
}
```

In case no $PIPESTATUS is available, the status segment will fall back
to the exit code of the last command using the status template
for rendering.

The `{{ .Meaning }}` property has been marked as deprecated and can be
replaced with `{{ reason .Code }}`, allowing it to be reused in
cross segment templates.

resolves #4070
This commit is contained in:
Jan De Dobbeleer 2023-07-23 09:29:54 +02:00 committed by Jan De Dobbeleer
parent 2da3722521
commit f47da9592f
109 changed files with 470 additions and 330 deletions

2
.vscode/launch.json vendored
View file

@ -40,7 +40,7 @@
"print", "print",
"transient", "transient",
"--shell=pwsh", "--shell=pwsh",
"--error=1" "--status=1"
] ]
}, },
{ {

View file

@ -12,7 +12,8 @@ import (
var ( var (
pwd string pwd string
pswd string pswd string
exitCode int status int
pipestatus string
timing float64 timing float64
stackCount int stackCount int
terminalWidth int terminalWidth int
@ -22,7 +23,7 @@ var (
command string command string
shellVersion string shellVersion string
plain bool plain bool
noExitCode bool noStatus bool
) )
// printCmd represents the prompt command // printCmd represents the prompt command
@ -51,7 +52,8 @@ var printCmd = &cobra.Command{
Config: config, Config: config,
PWD: pwd, PWD: pwd,
PSWD: pswd, PSWD: pswd,
ErrorCode: exitCode, ErrorCode: status,
PipeStatus: pipestatus,
ExecutionTime: timing, ExecutionTime: timing,
StackCount: stackCount, StackCount: stackCount,
TerminalWidth: terminalWidth, TerminalWidth: terminalWidth,
@ -61,7 +63,7 @@ var printCmd = &cobra.Command{
Plain: plain, Plain: plain,
Primary: args[0] == "primary", Primary: args[0] == "primary",
Cleared: cleared, Cleared: cleared,
NoExitCode: noExitCode, NoExitCode: noStatus,
} }
eng := engine.New(flags) eng := engine.New(flags)
@ -95,7 +97,9 @@ func init() { //nolint:gochecknoinits
printCmd.Flags().StringVar(&pswd, "pswd", "", "current working directory (according to pwsh)") printCmd.Flags().StringVar(&pswd, "pswd", "", "current working directory (according to pwsh)")
printCmd.Flags().StringVar(&shellName, "shell", "", "the shell to print for") printCmd.Flags().StringVar(&shellName, "shell", "", "the shell to print for")
printCmd.Flags().StringVar(&shellVersion, "shell-version", "", "the shell version") printCmd.Flags().StringVar(&shellVersion, "shell-version", "", "the shell version")
printCmd.Flags().IntVarP(&exitCode, "error", "e", 0, "last exit code") printCmd.Flags().IntVar(&status, "status", 0, "last known status code")
printCmd.Flags().BoolVar(&noStatus, "no-status", false, "no valid status code (cancelled or no command yet)")
printCmd.Flags().StringVar(&pipestatus, "pipestatus", "", "the PIPESTATUS array")
printCmd.Flags().Float64Var(&timing, "execution-time", 0, "timing of the last command") printCmd.Flags().Float64Var(&timing, "execution-time", 0, "timing of the last command")
printCmd.Flags().IntVarP(&stackCount, "stack-count", "s", 0, "number of locations on the stack") printCmd.Flags().IntVarP(&stackCount, "stack-count", "s", 0, "number of locations on the stack")
printCmd.Flags().IntVarP(&terminalWidth, "terminal-width", "w", 0, "width of the terminal") printCmd.Flags().IntVarP(&terminalWidth, "terminal-width", "w", 0, "width of the terminal")
@ -103,6 +107,8 @@ func init() { //nolint:gochecknoinits
printCmd.Flags().BoolVarP(&plain, "plain", "p", false, "plain text output (no ANSI)") printCmd.Flags().BoolVarP(&plain, "plain", "p", false, "plain text output (no ANSI)")
printCmd.Flags().BoolVar(&cleared, "cleared", false, "do we have a clear terminal or not") printCmd.Flags().BoolVar(&cleared, "cleared", false, "do we have a clear terminal or not")
printCmd.Flags().BoolVar(&eval, "eval", false, "output the prompt for eval") printCmd.Flags().BoolVar(&eval, "eval", false, "output the prompt for eval")
printCmd.Flags().BoolVar(&noExitCode, "no-exit-code", false, "no valid exit code (cancelled or no command yet)") // Deprecated flags
printCmd.Flags().IntVarP(&status, "error", "e", 0, "last exit code")
printCmd.Flags().BoolVar(&noStatus, "no-exit-code", false, "no valid exit code (cancelled or no command yet)")
RootCmd.AddCommand(printCmd) RootCmd.AddCommand(printCmd)
} }

View file

@ -135,7 +135,7 @@ func (segment *Segment) migrationOne(env platform.Environment) {
segment.migrateColorOverride("version_mismatch_color", "{{ if .Mismatch }}%s{{ end }}", background) segment.migrateColorOverride("version_mismatch_color", "{{ if .Mismatch }}%s{{ end }}", background)
} }
case EXIT: case EXIT:
template := segment.Properties.GetString(segmentTemplate, segment.writer.Template()) template := segment.Properties.GetString(segmentTemplate, "{{ if gt .Code 0 }}\uf00d {{ .Meaning }}{{ else }}\uf42e{{ end }}")
if strings.Contains(template, ".Text") { if strings.Contains(template, ".Text") {
template = strings.ReplaceAll(template, ".Text", ".Meaning") template = strings.ReplaceAll(template, ".Text", ".Meaning")
segment.Properties[segmentTemplate] = template segment.Properties[segmentTemplate] = template

View file

@ -9,6 +9,7 @@ import (
"github.com/jandedobbeleer/oh-my-posh/src/segments" "github.com/jandedobbeleer/oh-my-posh/src/segments"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
mock2 "github.com/stretchr/testify/mock"
) )
const ( const (
@ -326,7 +327,9 @@ func TestSegmentTemplateMigration(t *testing.T) {
Type: tc.Type, Type: tc.Type,
Properties: tc.Props, Properties: tc.Props,
} }
segment.migrationOne(&mock.MockedEnvironment{}) env := &mock.MockedEnvironment{}
env.On("Debug", mock2.Anything).Return(nil)
segment.migrationOne(env)
assert.Equal(t, tc.Expected, segment.Properties[segmentTemplate], tc.Case) assert.Equal(t, tc.Expected, segment.Properties[segmentTemplate], tc.Case)
} }
} }

View file

@ -21,7 +21,7 @@ const (
func (e *Engine) Primary() string { func (e *Engine) Primary() string {
if e.Config.ShellIntegration { if e.Config.ShellIntegration {
exitCode := e.Env.ErrorCode() exitCode, _ := e.Env.StatusCodes()
e.write(e.Writer.CommandFinished(exitCode, e.Env.Flags().NoExitCode)) e.write(e.Writer.CommandFinished(exitCode, e.Env.Flags().NoExitCode))
e.write(e.Writer.PromptStart()) e.write(e.Writer.PromptStart())
} }
@ -150,7 +150,7 @@ func (e *Engine) ExtraPrompt(promptType ExtraPromptType) string {
} }
if promptType == Transient && e.Config.ShellIntegration { if promptType == Transient && e.Config.ShellIntegration {
exitCode := e.Env.ErrorCode() exitCode, _ := e.Env.StatusCodes()
e.write(e.Writer.CommandFinished(exitCode, e.Env.Flags().NoExitCode)) e.write(e.Writer.CommandFinished(exitCode, e.Env.Flags().NoExitCode))
e.write(e.Writer.PromptStart()) e.write(e.Writer.PromptStart())
} }

View file

@ -217,6 +217,8 @@ const (
SITECORE SegmentType = "sitecore" SITECORE SegmentType = "sitecore"
// SPOTIFY writes the SPOTIFY status for Mac // SPOTIFY writes the SPOTIFY status for Mac
SPOTIFY SegmentType = "spotify" SPOTIFY SegmentType = "spotify"
// STATUS writes the last know command status
STATUS SegmentType = "status"
// STRAVA is a sports activity tracker // STRAVA is a sports activity tracker
STRAVA SegmentType = "strava" STRAVA SegmentType = "strava"
// Subversion segment // Subversion segment
@ -275,7 +277,7 @@ var Segments = map[SegmentType]func() SegmentWriter{
DOTNET: func() SegmentWriter { return &segments.Dotnet{} }, DOTNET: func() SegmentWriter { return &segments.Dotnet{} },
EXECUTIONTIME: func() SegmentWriter { return &segments.Executiontime{} }, EXECUTIONTIME: func() SegmentWriter { return &segments.Executiontime{} },
ELIXIR: func() SegmentWriter { return &segments.Elixir{} }, ELIXIR: func() SegmentWriter { return &segments.Elixir{} },
EXIT: func() SegmentWriter { return &segments.Exit{} }, EXIT: func() SegmentWriter { return &segments.Status{} },
FLUTTER: func() SegmentWriter { return &segments.Flutter{} }, FLUTTER: func() SegmentWriter { return &segments.Flutter{} },
FOSSIL: func() SegmentWriter { return &segments.Fossil{} }, FOSSIL: func() SegmentWriter { return &segments.Fossil{} },
GCP: func() SegmentWriter { return &segments.Gcp{} }, GCP: func() SegmentWriter { return &segments.Gcp{} },
@ -314,6 +316,7 @@ var Segments = map[SegmentType]func() SegmentWriter{
SHELL: func() SegmentWriter { return &segments.Shell{} }, SHELL: func() SegmentWriter { return &segments.Shell{} },
SITECORE: func() SegmentWriter { return &segments.Sitecore{} }, SITECORE: func() SegmentWriter { return &segments.Sitecore{} },
SPOTIFY: func() SegmentWriter { return &segments.Spotify{} }, SPOTIFY: func() SegmentWriter { return &segments.Spotify{} },
STATUS: func() SegmentWriter { return &segments.Status{} },
STRAVA: func() SegmentWriter { return &segments.Strava{} }, STRAVA: func() SegmentWriter { return &segments.Strava{} },
SVN: func() SegmentWriter { return &segments.Svn{} }, SVN: func() SegmentWriter { return &segments.Svn{} },
SWIFT: func() SegmentWriter { return &segments.Swift{} }, SWIFT: func() SegmentWriter { return &segments.Swift{} },

View file

@ -105,9 +105,9 @@ func (env *MockedEnvironment) RunShellCommand(shell, command string) string {
return args.String(0) return args.String(0)
} }
func (env *MockedEnvironment) ErrorCode() int { func (env *MockedEnvironment) StatusCodes() (int, string) {
args := env.Called() args := env.Called()
return args.Int(0) return args.Int(0), args.String(1)
} }
func (env *MockedEnvironment) ExecutionTime() float64 { func (env *MockedEnvironment) ExecutionTime() float64 {

View file

@ -52,6 +52,7 @@ var (
type Flags struct { type Flags struct {
ErrorCode int ErrorCode int
PipeStatus string
Config string Config string
Shell string Shell string
ShellVersion string ShellVersion string
@ -215,7 +216,7 @@ type Environment interface {
GOOS() string GOOS() string
Shell() string Shell() string
Platform() string Platform() string
ErrorCode() int StatusCodes() (int, string)
PathSeparator() string PathSeparator() string
HasFiles(pattern string) bool HasFiles(pattern string) bool
HasFilesInDir(dir, pattern string) bool HasFilesInDir(dir, pattern string) bool
@ -611,9 +612,9 @@ func (env *Shell) HasCommand(command string) bool {
return false return false
} }
func (env *Shell) ErrorCode() int { func (env *Shell) StatusCodes() (int, string) {
defer env.Trace(time.Now()) defer env.Trace(time.Now())
return env.CmdFlags.ErrorCode return env.CmdFlags.ErrorCode, env.CmdFlags.PipeStatus
} }
func (env *Shell) ExecutionTime() float64 { func (env *Shell) ExecutionTime() float64 {
@ -798,7 +799,7 @@ func (env *Shell) TemplateCache() *TemplateCache {
tmplCache.Root = env.Root() tmplCache.Root = env.Root()
tmplCache.Shell = env.Shell() tmplCache.Shell = env.Shell()
tmplCache.ShellVersion = env.CmdFlags.ShellVersion tmplCache.ShellVersion = env.CmdFlags.ShellVersion
tmplCache.Code = env.ErrorCode() tmplCache.Code, _ = env.StatusCodes()
tmplCache.WSL = env.IsWsl() tmplCache.WSL = env.IsWsl()
tmplCache.Segments = make(map[string]interface{}) tmplCache.Segments = make(map[string]interface{})
tmplCache.PromptCount = env.CmdFlags.PromptCount tmplCache.PromptCount = env.CmdFlags.PromptCount

View file

@ -1,92 +0,0 @@
package segments
import (
"testing"
"github.com/jandedobbeleer/oh-my-posh/src/mock"
"github.com/jandedobbeleer/oh-my-posh/src/platform"
"github.com/jandedobbeleer/oh-my-posh/src/properties"
"github.com/stretchr/testify/assert"
)
func TestExitWriterEnabled(t *testing.T) {
cases := []struct {
ExitCode int
Expected bool
}{
{ExitCode: 102, Expected: true},
{ExitCode: 0, Expected: false},
{ExitCode: -1, Expected: true},
}
for _, tc := range cases {
env := new(mock.MockedEnvironment)
env.On("ErrorCode").Return(tc.ExitCode)
e := &Exit{
env: env,
props: properties.Map{},
}
assert.Equal(t, tc.Expected, e.Enabled())
}
}
func TestGetMeaningFromExitCode(t *testing.T) {
errorMap := make(map[int]string)
errorMap[1] = "ERROR"
errorMap[2] = "USAGE"
errorMap[126] = "NOPERM"
errorMap[127] = "NOTFOUND"
errorMap[129] = "SIGHUP"
errorMap[130] = "SIGINT"
errorMap[131] = "SIGQUIT"
errorMap[132] = "SIGILL"
errorMap[133] = "SIGTRAP"
errorMap[134] = "SIGIOT"
errorMap[135] = "SIGBUS"
errorMap[136] = "SIGFPE"
errorMap[137] = "SIGKILL"
errorMap[138] = "SIGUSR1"
errorMap[139] = "SIGSEGV"
errorMap[140] = "SIGUSR2"
errorMap[141] = "SIGPIPE"
errorMap[142] = "SIGALRM"
errorMap[143] = "SIGTERM"
errorMap[144] = "SIGSTKFLT"
errorMap[145] = "SIGCHLD"
errorMap[146] = "SIGCONT"
errorMap[147] = "SIGSTOP"
errorMap[148] = "SIGTSTP"
errorMap[149] = "SIGTTIN"
errorMap[150] = "SIGTTOU"
errorMap[151] = "151"
errorMap[7000] = "7000"
for exitcode, want := range errorMap {
e := &Exit{}
assert.Equal(t, want, e.getMeaningFromExitCode(exitcode))
}
}
func TestExitWriterTemplateString(t *testing.T) {
cases := []struct {
Case string
ExitCode int
Expected string
Template string
}{
{Case: "Only code", ExitCode: 129, Expected: "129", Template: "{{ .Code }}"},
}
for _, tc := range cases {
env := new(mock.MockedEnvironment)
env.On("ErrorCode").Return(tc.ExitCode)
env.On("TemplateCache").Return(&platform.TemplateCache{
Code: tc.ExitCode,
})
e := &Exit{
env: env,
props: properties.Map{},
}
assert.Equal(t, tc.Expected, renderTemplate(env, tc.Template, e), tc.Case)
}
}

109
src/segments/status.go Normal file
View file

@ -0,0 +1,109 @@
package segments
import (
"strconv"
"strings"
"github.com/jandedobbeleer/oh-my-posh/src/platform"
"github.com/jandedobbeleer/oh-my-posh/src/properties"
"github.com/jandedobbeleer/oh-my-posh/src/template"
)
const (
StatusTemplate properties.Property = "status_template"
StatusSeparator properties.Property = "status_separator"
)
type Status struct {
props properties.Properties
env platform.Environment
String string
Error bool
Code int
template *template.Text
// Deprecated: Use {{ reason .Code }} instead
Meaning string
}
func (s *Status) Template() string {
return " {{ .String }} "
}
func (s *Status) Enabled() bool {
status, pipeStatus := s.env.StatusCodes()
s.String = s.formatStatus(status, pipeStatus)
// Deprecated: Use {{ reason .Code }} instead
s.Meaning = template.GetReasonFromStatus(status)
if s.props.GetBool(properties.AlwaysEnabled, false) {
return true
}
return s.Error
}
func (s *Status) Init(props properties.Properties, env platform.Environment) {
s.props = props
s.env = env
statusTemplate := s.props.GetString(StatusTemplate, "{{ .Code }}")
s.template = &template.Text{
Template: statusTemplate,
Env: s.env,
}
}
func (s *Status) formatStatus(status int, pipeStatus string) string {
if status != 0 {
s.Error = true
}
if len(pipeStatus) == 0 {
s.Code = status
s.template.Context = s
if text, err := s.template.Render(); err == nil {
return text
}
return strconv.Itoa(status)
}
StatusSeparator := s.props.GetString(StatusSeparator, "|")
var builder strings.Builder
splitted := strings.Split(pipeStatus, " ")
for i, codeStr := range splitted {
write := func(text string) {
if i > 0 {
builder.WriteString(StatusSeparator)
}
builder.WriteString(text)
}
code, err := strconv.Atoi(codeStr)
if err != nil {
write(codeStr)
continue
}
if code != 0 {
s.Error = true
}
s.Code = code
s.template.Context = s
text, err := s.template.Render()
if err != nil {
write(codeStr)
continue
}
write(text)
}
return builder.String()
}

106
src/segments/status_test.go Normal file
View file

@ -0,0 +1,106 @@
package segments
import (
"testing"
"github.com/jandedobbeleer/oh-my-posh/src/mock"
"github.com/jandedobbeleer/oh-my-posh/src/platform"
"github.com/jandedobbeleer/oh-my-posh/src/properties"
"github.com/stretchr/testify/assert"
mock2 "github.com/stretchr/testify/mock"
)
func TestStatusWriterEnabled(t *testing.T) {
cases := []struct {
Status int
Expected bool
Template string
}{
{Status: 102, Expected: true},
{Status: 0, Expected: false},
{Status: -1, Expected: true},
{Status: 144, Expected: true, Template: "{{}}"},
}
for _, tc := range cases {
env := new(mock.MockedEnvironment)
env.On("StatusCodes").Return(tc.Status, "")
env.On("TemplateCache").Return(&platform.TemplateCache{
Code: 133,
})
env.On("Error", mock2.Anything).Return(nil)
props := properties.Map{}
if len(tc.Template) > 0 {
props[StatusTemplate] = tc.Template
}
s := &Status{}
s.Init(props, env)
assert.Equal(t, tc.Expected, s.Enabled())
}
}
func TestFormatStatus(t *testing.T) {
cases := []struct {
Case string
Status int
PipeStatus string
Template string
Separator string
Expected string
}{
{
Case: "No PipeStatus",
Status: 12,
Template: "{{ .Code }}",
Separator: "|",
Expected: "12",
},
{
Case: "Defaults",
PipeStatus: "0 127 0",
Template: "{{ .Code }}",
Separator: "|",
Expected: "0|127|0",
},
{
Case: "No integer",
PipeStatus: "0 err 0",
Template: "{{ .Code }}",
Separator: "|",
Expected: "0|err|0",
},
{
Case: "Incorrect template",
PipeStatus: "1 0 0",
Template: "{{}}",
Separator: "|",
Expected: "1|0|0",
},
{
Case: "Advanced template",
PipeStatus: "1 0 0",
Template: "{{ if eq .Code 0 }}\uf058{{ else }}\uf071{{ end }}",
Separator: "|",
Expected: "\uf071|\uf058|\uf058",
},
}
for _, tc := range cases {
env := new(mock.MockedEnvironment)
env.On("TemplateCache").Return(&platform.TemplateCache{
Code: 133,
})
env.On("Error", mock2.Anything).Return(nil)
props := properties.Map{
StatusTemplate: tc.Template,
StatusSeparator: tc.Separator,
}
s := &Status{}
s.Init(props, env)
assert.Equal(t, tc.Expected, s.formatStatus(tc.Status, tc.PipeStatus), tc.Case)
}
}

View file

@ -46,19 +46,26 @@ function set_poshcontext() {
} }
function _omp_hook() { function _omp_hook() {
local ret=$? local ret=$? pipeStatus=(${PIPESTATUS[@]})
if [[ "${#BP_PIPESTATUS[@]}" -gt "${#pipeStatus[@]}" ]]; then
pipeStatus=(${BP_PIPESTATUS[@]})
fi
local omp_stack_count=$((${#DIRSTACK[@]} - 1)) local omp_stack_count=$((${#DIRSTACK[@]} - 1))
local omp_elapsed=-1 local omp_elapsed=-1
local no_exit_code="true" local no_exit_code="true"
if [[ -n "$omp_start_time" ]]; then if [[ -n "$omp_start_time" ]]; then
local omp_now=$(::OMP:: get millis --shell=bash) local omp_now=$(::OMP:: get millis --shell=bash)
omp_elapsed=$((omp_now-omp_start_time)) omp_elapsed=$((omp_now-omp_start_time))
omp_start_time="" omp_start_time=""
no_exit_code="false" no_exit_code="false"
fi fi
set_poshcontext set_poshcontext
_set_posh_cursor_position _set_posh_cursor_position
PS1="$(::OMP:: print primary --config="$POSH_THEME" --shell=bash --shell-version="$BASH_VERSION" --error="$ret" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count" --no-exit-code="$no_exit_code" | tr -d '\0')"
PS1="$(::OMP:: print primary --config="$POSH_THEME" --shell=bash --shell-version="$BASH_VERSION" --status="$ret" --pipestatus="${pipeStatus[*]}" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count" --no-status="$no_exit_code" | tr -d '\0')"
return $ret return $ret
} }

View file

@ -23,12 +23,12 @@ set edit:after-command = [ $@edit:after-command $posh-after-command-hook~ ]
set edit:prompt = { set edit:prompt = {
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000)) var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
::OMP:: print primary --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --error=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION ::OMP:: print primary --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --status=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION
} }
set edit:rprompt = { set edit:rprompt = {
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000)) var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
::OMP:: print right --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --error=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION ::OMP:: print right --config=$E:POSH_THEME --shell=elvish --execution-time=$cmd-duration --status=$error-code --pwd=$pwd --shell-version=$E:POSH_SHELL_VERSION
} }
if (eq '::UPGRADE::' 'true') { if (eq '::UPGRADE::' 'true') {

View file

@ -14,15 +14,17 @@ end
function fish_prompt function fish_prompt
set --local omp_status_cache_temp $status set --local omp_status_cache_temp $status
set --local omp_pipestatus_cache_temp $pipestatus
# clear from cursor to end of screen as # clear from cursor to end of screen as
# commandline --function repaint does not do this # commandline --function repaint does not do this
# see https://github.com/fish-shell/fish-shell/issues/8418 # see https://github.com/fish-shell/fish-shell/issues/8418
printf \e\[0J printf \e\[0J
if test "$omp_transient" = "1" if test "$omp_transient" = "1"
::OMP:: print transient --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION --no-exit-code=$omp_no_exit_code ::OMP:: print transient --config $POSH_THEME --shell fish --status $omp_status_cache --pipestatus="$omp_pipestatus_cache" --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION --no-status=$omp_no_exit_code
return return
end end
set --global omp_status_cache $omp_status_cache_temp set --global omp_status_cache $omp_status_cache_temp
set --global omp_pipestatus_cache $omp_pipestatus_cache_temp
set --global omp_stack_count (count $dirstack) set --global omp_stack_count (count $dirstack)
set --global omp_duration "$CMD_DURATION$cmd_duration" set --global omp_duration "$CMD_DURATION$cmd_duration"
set --global omp_no_exit_code false set --global omp_no_exit_code false
@ -49,7 +51,7 @@ function fish_prompt
if test "$last_command" = "clear" if test "$last_command" = "clear"
set omp_cleared true set omp_cleared true
end end
::OMP:: print primary --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION --cleared=$omp_cleared --no-exit-code=$omp_no_exit_code ::OMP:: print primary --config $POSH_THEME --shell fish --status $omp_status_cache --pipestatus="$omp_pipestatus_cache" --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION --cleared=$omp_cleared --no-status=$omp_no_exit_code
end end
function fish_right_prompt function fish_right_prompt
@ -66,7 +68,7 @@ function fish_right_prompt
return return
end end
set has_omp_tooltip false set has_omp_tooltip false
::OMP:: print right --config $POSH_THEME --shell fish --error $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION ::OMP:: print right --config $POSH_THEME --shell fish --status $omp_status_cache --execution-time $omp_duration --stack-count $omp_stack_count --shell-version $FISH_VERSION
end end
function postexec_omp --on-event fish_postexec function postexec_omp --on-event fish_postexec
@ -104,7 +106,7 @@ function _render_tooltip
if not test -n "$omp_tooltip_command" if not test -n "$omp_tooltip_command"
return return
end end
set omp_tooltip_prompt (::OMP:: print tooltip --config $POSH_THEME --shell fish --error $omp_status_cache --shell-version $FISH_VERSION --command $omp_tooltip_command) set omp_tooltip_prompt (::OMP:: print tooltip --config $POSH_THEME --shell fish --status $omp_status_cache --shell-version $FISH_VERSION --command $omp_tooltip_command)
if not test -n "$omp_tooltip_prompt" if not test -n "$omp_tooltip_prompt"
if test "$has_omp_tooltip" = "true" if test "$has_omp_tooltip" = "true"
commandline --function repaint commandline --function repaint

View file

@ -142,14 +142,14 @@ end
local function error_level_option() local function error_level_option()
if os.geterrorlevel ~= nil and settings.get("cmd.get_errorlevel") then if os.geterrorlevel ~= nil and settings.get("cmd.get_errorlevel") then
return "--error "..os.geterrorlevel() return "--status "..os.geterrorlevel()
end end
return "" return ""
end end
local function no_exit_code_option() local function no_exit_code_option()
if no_exit_code then if no_exit_code then
return "--no-exit-code" return "--no-status"
end end
return "" return ""
end end

View file

@ -23,7 +23,7 @@ export-env {
let clear = (history | last 1 | get 0.command) == "clear" let clear = (history | last 1 | get 0.command) == "clear"
let width = ((term size).columns | into string) let width = ((term size).columns | into string)
^::OMP:: print primary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)" $"--execution-time=($cmd_duration)" $"--error=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" $"--cleared=($clear)" ^::OMP:: print primary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.POSH_SHELL_VERSION)" $"--execution-time=($cmd_duration)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" $"--cleared=($clear)"
} }
} }

View file

@ -132,7 +132,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
} }
$position = $host.UI.RawUI.CursorPosition $position = $host.UI.RawUI.CursorPosition
$cleanPSWD = Get-CleanPSWD $cleanPSWD = Get-CleanPSWD
$standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", "tooltip", "--error=$script:ErrorCode", "--shell=$script:ShellName", "--pswd=$cleanPSWD", "--config=$env:POSH_THEME", "--command=$command", "--shell-version=$script:PSVersion")) $standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", "tooltip", "--status=$script:ErrorCode", "--shell=$script:ShellName", "--pswd=$cleanPSWD", "--config=$env:POSH_THEME", "--command=$command", "--shell-version=$script:PSVersion"))
# ignore an empty tooltip # ignore an empty tooltip
if ($standardOut -eq '') { if ($standardOut -eq '') {
return return
@ -420,7 +420,7 @@ Example:
$env:POSH_CURSOR_LINE = $Host.UI.RawUI.CursorPosition.Y + 1 $env:POSH_CURSOR_LINE = $Host.UI.RawUI.CursorPosition.Y + 1
$env:POSH_CURSOR_COLUMN = $Host.UI.RawUI.CursorPosition.X + 1 $env:POSH_CURSOR_COLUMN = $Host.UI.RawUI.CursorPosition.X + 1
$standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", $script:PromptType, "--error=$script:ErrorCode", "--pswd=$cleanPSWD", "--execution-time=$script:ExecutionTime", "--stack-count=$stackCount", "--config=$env:POSH_THEME", "--shell-version=$script:PSVersion", "--terminal-width=$terminalWidth", "--shell=$script:ShellName", "--no-exit-code=$script:NoExitCode")) $standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", $script:PromptType, "--status=$script:ErrorCode", "--pswd=$cleanPSWD", "--execution-time=$script:ExecutionTime", "--stack-count=$stackCount", "--config=$env:POSH_THEME", "--shell-version=$script:PSVersion", "--terminal-width=$terminalWidth", "--shell=$script:ShellName", "--no-status=$script:NoExitCode"))
# make sure PSReadLine knows if we have a multiline prompt # make sure PSReadLine knows if we have a multiline prompt
Set-PSReadLineOption -ExtraPromptLineCount (($standardOut | Measure-Object -Line).Lines - 1) Set-PSReadLineOption -ExtraPromptLineCount (($standardOut | Measure-Object -Line).Lines - 1)
# the output can be multiline, joining these ensures proper rendering by adding line breaks with `n # the output can be multiline, joining these ensures proper rendering by adding line breaks with `n

View file

@ -13,11 +13,11 @@ def get_command_context():
def posh_primary(): def posh_primary():
status, duration = get_command_context() status, duration = get_command_context()
return $(::OMP:: print primary --config=@($POSH_THEME) --shell=xonsh --error=@(status) --execution-time=@(duration) --shell-version=@($POSH_SHELL_VERSION)) return $(::OMP:: print primary --config=@($POSH_THEME) --shell=xonsh --status=@(status) --execution-time=@(duration) --shell-version=@($POSH_SHELL_VERSION))
def posh_right(): def posh_right():
status, duration = get_command_context() status, duration = get_command_context()
return $(::OMP:: print right --config=@($POSH_THEME) --shell=xonsh --error=@(status) --execution-time=@(duration) --shell-version=@($POSH_SHELL_VERSION)) return $(::OMP:: print right --config=@($POSH_THEME) --shell=xonsh --status=@(status) --execution-time=@(duration) --shell-version=@($POSH_SHELL_VERSION))
$PROMPT = posh_primary $PROMPT = posh_primary

View file

@ -4,7 +4,7 @@ setenv POSH_SHELL_VERSION "";
set USER_PRECMD = "`alias precmd`"; set USER_PRECMD = "`alias precmd`";
set USER_POSTCMD = "`alias postcmd`"; set USER_POSTCMD = "`alias postcmd`";
set POSH_PRECMD = 'set POSH_CMD_STATUS = $status;set POSH_PATH = ::OMP::;set POSH_END_TIME = `$POSH_PATH get millis`;set POSH_DURATION = 0;if ( $POSH_START_TIME != -1 ) @ POSH_DURATION = $POSH_END_TIME - $POSH_START_TIME;set prompt = "`$POSH_PATH print primary --shell=tcsh --config=$POSH_THEME --error=$POSH_CMD_STATUS --execution-time=$POSH_DURATION`";set POSH_START_TIME = -1'; set POSH_PRECMD = 'set POSH_CMD_STATUS = $status;set POSH_PATH = ::OMP::;set POSH_END_TIME = `$POSH_PATH get millis`;set POSH_DURATION = 0;if ( $POSH_START_TIME != -1 ) @ POSH_DURATION = $POSH_END_TIME - $POSH_START_TIME;set prompt = "`$POSH_PATH print primary --shell=tcsh --config=$POSH_THEME --status=$POSH_CMD_STATUS --execution-time=$POSH_DURATION`";set POSH_START_TIME = -1';
set POSH_POSTCMD = 'set POSH_START_TIME = `::OMP:: get millis`'; set POSH_POSTCMD = 'set POSH_START_TIME = `::OMP:: get millis`';
alias precmd "$POSH_PRECMD;$USER_PRECMD"; alias precmd "$POSH_PRECMD;$USER_PRECMD";
alias postcmd "$POSH_POSTCMD;$USER_POSTCMD"; alias postcmd "$POSH_POSTCMD;$USER_POSTCMD";

View file

@ -43,7 +43,7 @@ function prompt_ohmyposh_preexec() {
} }
function prompt_ohmyposh_precmd() { function prompt_ohmyposh_precmd() {
omp_last_error=$? omp_last_error=$? pipeStatus=(${pipestatus[@]})
omp_stack_count=${#dirstack[@]} omp_stack_count=${#dirstack[@]}
omp_elapsed=-1 omp_elapsed=-1
no_exit_code="true" no_exit_code="true"
@ -56,7 +56,7 @@ function prompt_ohmyposh_precmd() {
export POSH_PROMPT_COUNT=$count export POSH_PROMPT_COUNT=$count
set_poshcontext set_poshcontext
_set_posh_cursor_position _set_posh_cursor_position
eval "$(::OMP:: print primary --config="$POSH_THEME" --error="$omp_last_error" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count" --eval --shell=zsh --shell-version="$ZSH_VERSION" --no-exit-code="$no_exit_code")" eval "$(::OMP:: print primary --config="$POSH_THEME" --status="$omp_last_error" --pipestatus="${pipeStatus[*]}" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count" --eval --shell=zsh --shell-version="$ZSH_VERSION" --no-status="$no_exit_code")"
unset omp_start_time unset omp_start_time
} }
@ -96,7 +96,7 @@ function _posh-tooltip() {
if [[ -z "$tip" ]]; then if [[ -z "$tip" ]]; then
return return
fi fi
local tooltip=$(::OMP:: print tooltip --config="$POSH_THEME" --shell=zsh --error="$omp_last_error" --command="$tip" --shell-version="$ZSH_VERSION") local tooltip=$(::OMP:: print tooltip --config="$POSH_THEME" --shell=zsh --status="$omp_last_error" --command="$tip" --shell-version="$ZSH_VERSION")
# ignore an empty tooltip # ignore an empty tooltip
if [[ -z "$tooltip" ]]; then if [[ -z "$tooltip" ]]; then
return return
@ -114,7 +114,7 @@ function _posh-zle-line-init() {
local -i ret=$? local -i ret=$?
(( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[2] (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[2]
eval "$(::OMP:: print transient --error="$omp_last_error" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count" --config="$POSH_THEME" --eval --shell=zsh --shell-version="$ZSH_VERSION" --no-exit-code="$no_exit_code")" eval "$(::OMP:: print transient --status="$omp_last_error" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count" --config="$POSH_THEME" --eval --shell=zsh --shell-version="$ZSH_VERSION" --no-status="$no_exit_code")"
zle .reset-prompt zle .reset-prompt
# If we received EOT, we exit the shell # If we received EOT, we exit the shell

View file

@ -16,6 +16,7 @@ func funcMap() template.FuncMap {
"replaceP": replaceP, "replaceP": replaceP,
"gt": gt, "gt": gt,
"lt": lt, "lt": lt,
"reason": GetReasonFromStatus,
} }
for key, fun := range sprig.TxtFuncMap() { for key, fun := range sprig.TxtFuncMap() {
if _, ok := funcMap[key]; !ok { if _, ok := funcMap[key]; !ok {

View file

@ -1,37 +1,8 @@
package segments package template
import ( import "strconv"
"strconv"
"github.com/jandedobbeleer/oh-my-posh/src/platform" func GetReasonFromStatus(code int) string { //nolint: gocyclo
"github.com/jandedobbeleer/oh-my-posh/src/properties"
)
type Exit struct {
props properties.Properties
env platform.Environment
Meaning string
}
func (e *Exit) Template() string {
return " {{ if gt .Code 0 }}\uf00d {{ .Meaning }}{{ else }}\uf42e{{ end }} "
}
func (e *Exit) Enabled() bool {
e.Meaning = e.getMeaningFromExitCode(e.env.ErrorCode())
if e.props.GetBool(properties.AlwaysEnabled, false) {
return true
}
return e.env.ErrorCode() != 0
}
func (e *Exit) Init(props properties.Properties, env platform.Environment) {
e.props = props
e.env = env
}
func (e *Exit) getMeaningFromExitCode(code int) string { //nolint: gocyclo
switch code { switch code {
case 1: case 1:
return "ERROR" return "ERROR"

View file

@ -208,6 +208,8 @@ func (f *fields) init(data interface{}) {
for key := range m { for key := range m {
(*f)[key] = true (*f)[key] = true
} }
case reflect.Ptr:
f.init(reflect.ValueOf(data).Elem().Interface())
} }
} }

View file

@ -161,7 +161,7 @@
"style": "diamond", "style": "diamond",
"template": "<parentBackground>\ue0b0</> \ue23a ", "template": "<parentBackground>\ue0b0</> \ue23a ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -161,7 +161,7 @@
"style": "diamond", "style": "diamond",
"template": "<parentBackground>\ue0b0</> \ue23a ", "template": "<parentBackground>\ue0b0</> \ue23a ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -109,7 +109,7 @@
}, },
"style": "plain", "style": "plain",
"template": " \ue286 ", "template": " \ue286 ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -7,8 +7,8 @@
{ {
"foreground": "#ffffff", "foreground": "#ffffff",
"style": "plain", "style": "plain",
"template": "{{ .Meaning }}\u274c ", "template": "{{ reason .Code }}\u274c ",
"type": "exit" "type": "status"
}, },
{ {
"foreground": "#ff0000", "foreground": "#ff0000",

View file

@ -55,8 +55,8 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"style": "powerline", "style": "powerline",
"template": " {{ .Meaning }} ", "template": " {{ reason .Code }} ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -266,7 +266,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\ue285\ueb9e ", "template": "\ue285\ueb9e ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -183,7 +183,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\ue285\ueb9e ", "template": "\ue285\ueb9e ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -28,8 +28,8 @@
{ {
"foreground": "#C94A16", "foreground": "#C94A16",
"style": "plain", "style": "plain",
"template": "x{{ .Meaning }} ", "template": "x{{ reason .Code }} ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -69,8 +69,8 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"style": "powerline", "style": "powerline",
"template": "<transparent> \uf12a</> {{ .Meaning }} ", "template": "<transparent> \uf12a</> {{ reason .Code }} ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"
@ -113,7 +113,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u276f ", "template": "\u276f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -97,7 +97,7 @@
"style": "diamond", "style": "diamond",
"template": " \uea6c ", "template": " \uea6c ",
"trailing_diamond": "\ue0b0", "trailing_diamond": "\ue0b0",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -58,7 +58,7 @@
"style": "diamond", "style": "diamond",
"template": " \ueb05 ", "template": " \ueb05 ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -120,7 +120,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u2570\u2500 ", "template": "\u2570\u2500 ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -105,7 +105,7 @@
"style": "powerline", "style": "powerline",
"powerline_symbol": "\ue0b4", "powerline_symbol": "\ue0b4",
"template": "{{ if eq .Code 0 }} \uf004 {{ end }}", "template": "{{ if eq .Code 0 }} \uf004 {{ end }}",
"type": "exit" "type": "status"
}, },
{ {
"background": "p:error-background", "background": "p:error-background",
@ -113,8 +113,8 @@
"leading_diamond": " \ue0c5", "leading_diamond": " \ue0c5",
"trailing_diamond": "\ue0c4", "trailing_diamond": "\ue0c4",
"style": "diamond", "style": "diamond",
"template": "{{ if ne .Code 0 }} \uf00d {{ .Code }}{{ if (ne .Meaning (toString .Code)) }} - {{ .Meaning }}{{else}}{{ end }} {{ end }}", "template": "{{ if ne .Code 0 }} \uf00d {{ .Code }}{{ if (ne (reason .Code) (toString .Code)) }} - {{ reason .Code }}{{else}}{{ end }} {{ end }}",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -54,9 +54,9 @@
"always_enabled": true "always_enabled": true
}, },
"style": "diamond", "style": "diamond",
"template": " \ue23a {{ if gt .Code 0 }}\uf00d {{ .Meaning }}{{ else }}\uf42e{{ end }} ", "template": " \ue23a {{ if gt .Code 0 }}\uf00d {{ reason .Code }}{{ else }}\uf42e{{ end }} ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -85,7 +85,7 @@
"powerline_symbol": "\ue0b4", "powerline_symbol": "\ue0b4",
"style": "powerline", "style": "powerline",
"template": " \ueb05 ", "template": " \ueb05 ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -25,8 +25,8 @@
{ {
"foreground": "#ffffff", "foreground": "#ffffff",
"style": "plain", "style": "plain",
"template": "<#CB4B16>[x</>{{ .Meaning }}<#CB4B16>]</>", "template": "<#CB4B16>[x</>{{ reason .Code }}<#CB4B16>]</>",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -53,13 +53,13 @@
"alignment": "right", "alignment": "right",
"segments": [ "segments": [
{ {
"type": "exit", "type": "status",
"style": "plain", "style": "plain",
"foreground": "#b8ff75", "foreground": "#b8ff75",
"foreground_templates": [ "foreground_templates": [
"{{ if gt .Code 0 }}#E06C75{{ end }}" "{{ if gt .Code 0 }}#E06C75{{ end }}"
], ],
"template": " x{{ .Meaning }}" "template": " x{{ reason .Code }}"
}, },
{ {
"foreground": "#b8ff75", "foreground": "#b8ff75",

View file

@ -41,8 +41,8 @@
{ {
"foreground": "#C94A16", "foreground": "#C94A16",
"style": "plain", "style": "plain",
"template": "x{{ .Meaning }} ", "template": "x{{ reason .Code }} ",
"type": "exit" "type": "status"
}, },
{ {
"foreground": "#E06C75", "foreground": "#E06C75",

View file

@ -7,8 +7,8 @@
{ {
"foreground": "#ffffff", "foreground": "#ffffff",
"style": "plain", "style": "plain",
"template": " {{ .Meaning }}", "template": " {{ reason .Code }}",
"type": "exit" "type": "status"
}, },
{ {
"foreground": "#100e23", "foreground": "#100e23",

View file

@ -93,7 +93,7 @@
"style": "diamond", "style": "diamond",
"template": " {{ if gt .Code 0 }}\uf421 \uf119 {{ else }}\uf469 \u2665 {{ end }}", "template": " {{ if gt .Code 0 }}\uf421 \uf119 {{ else }}\uf469 \u2665 {{ end }}",
"trailing_diamond": "\ue0b0", "trailing_diamond": "\ue0b0",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -90,8 +90,8 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"style": "powerline", "style": "powerline",
"template": "<transparent> \uf12a</> {{ .Meaning }} ", "template": "<transparent> \uf12a</> {{ reason .Code }} ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"
@ -138,7 +138,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u276f ", "template": "\u276f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -64,7 +64,7 @@ blocks:
properties: properties:
always_enabled: true always_enabled: true
style: diamond style: diamond
template: " {{ if gt .Code 0 }} {{ .Meaning }}{{ else }}{{ end }} " template: " {{ if gt .Code 0 }} {{ reason .Code }}{{ else }}{{ end }} "
trailing_diamond: trailing_diamond:
type: exit type: exit
type: prompt type: prompt

View file

@ -82,7 +82,7 @@
"style": "diamond", "style": "diamond",
"template": " \ueb05 ", "template": " \ueb05 ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -69,8 +69,8 @@
"always_enabled": true "always_enabled": true
}, },
"style": "plain", "style": "plain",
"template": "{{ if gt .Code 0 }}<parentBackground,background>\ue0b0</><transparent> \uf12a</> {{ .Meaning }} <background,transparent>\ue0b0</>{{ else }}<parentBackground,transparent>\ue0b0</>{{ end }}", "template": "{{ if gt .Code 0 }}<parentBackground,background>\ue0b0</><transparent> \uf12a</> {{ reason .Code }} <background,transparent>\ue0b0</>{{ else }}<parentBackground,transparent>\ue0b0</>{{ end }}",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"
@ -113,7 +113,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u276f ", "template": "\u276f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -61,8 +61,8 @@
{ {
"foreground": "#CB4B16", "foreground": "#CB4B16",
"style": "plain", "style": "plain",
"template": " {{ .Meaning }} ", "template": " {{ reason .Code }} ",
"type": "exit" "type": "status"
}, },
{ {
"foreground": "#CC4B16", "foreground": "#CC4B16",

View file

@ -119,7 +119,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u276f", "template": "\u276f",
"type": "exit" "type": "status"
} }
] ]
} }

View file

@ -156,7 +156,7 @@
}, },
"style": "plain", "style": "plain",
"template": " ", "template": " ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -65,7 +65,7 @@
}, },
"style": "powerline", "style": "powerline",
"template": " \uea6c ", "template": " \uea6c ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -161,7 +161,7 @@
"style": "diamond", "style": "diamond",
"template": "<parentBackground>\ue0b0</> \ue23a ", "template": "<parentBackground>\ue0b0</> \ue23a ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -86,9 +86,9 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"leading_diamond": "<transparent,background>\ue0b0</>", "leading_diamond": "<transparent,background>\ue0b0</>",
"style": "diamond", "style": "diamond",
"template": "<transparent> \uf12a</> {{ .Meaning }} ", "template": "<transparent> \uf12a</> {{ reason .Code }} ",
"trailing_diamond": "\ue0b0", "trailing_diamond": "\ue0b0",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -40,7 +40,7 @@
"style": "diamond", "style": "diamond",
"template": "<transparent>\ue0b0</>\ue23a ", "template": "<transparent>\ue0b0</>\ue23a ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -72,7 +72,7 @@
}, },
"style": "powerline", "style": "powerline",
"template": " {{ if gt .Code 0 }}\uf421{{ else }}\uf469 \u2665{{ end }} ", "template": " {{ if gt .Code 0 }}\uf421{{ else }}\uf469 \u2665{{ end }} ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -68,7 +68,7 @@
}, },
"style": "plain", "style": "plain",
"template": " {{ if gt .Code 0 }}\u2a2f{{else}}\u2713{{ end }} ", "template": " {{ if gt .Code 0 }}\u2a2f{{else}}\u2713{{ end }} ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -123,7 +123,7 @@
}, },
"style": "diamond", "style": "diamond",
"template": " {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} ", "template": " {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} ",
"type": "exit" "type": "status"
}, },
{ {
"background": "#575656", "background": "#575656",
@ -193,7 +193,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u276f ", "template": "\u276f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -77,9 +77,9 @@
"display_exit_code": true "display_exit_code": true
}, },
"style": "diamond", "style": "diamond",
"template": " {{ if gt .Code 0 }}\uf00d {{ .Meaning }}{{ else }}\uf00c{{ end }} ", "template": " {{ if gt .Code 0 }}\uf00d {{ reason .Code }}{{ else }}\uf00c{{ end }} ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -90,7 +90,7 @@
"style": "diamond", "style": "diamond",
"template": "<parentBackground>\ue0b0</> \ue23a ", "template": "<parentBackground>\ue0b0</> \ue23a ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -49,7 +49,7 @@
"style": "diamond", "style": "diamond",
"template": " \uf0e7 ", "template": " \uf0e7 ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -87,8 +87,8 @@
"foreground": "#fffef9", "foreground": "#fffef9",
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"style": "powerline", "style": "powerline",
"template": " \uf12a >>{{ .Meaning }} ", "template": " \uf12a >>{{ reason .Code }} ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -33,7 +33,7 @@
"foreground": "#DCB977", "foreground": "#DCB977",
"style": "plain", "style": "plain",
"template": " \uf119", "template": " \uf119",
"type": "exit" "type": "status"
}, },
{ {
"foreground": "#66F68F", "foreground": "#66F68F",

View file

@ -73,7 +73,7 @@
}, },
"style": "powerline", "style": "powerline",
"template": " \uea6c ", "template": " \uea6c ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -94,7 +94,7 @@
}, },
"style": "plain", "style": "plain",
"template": " {{ if gt .Code 0 }}\uf52f{{ else }}\uf4a7{{ end }} ", "template": " {{ if gt .Code 0 }}\uf52f{{ else }}\uf4a7{{ end }} ",
"type": "exit" "type": "status"
}, },
{ {
"foreground": "#ffffff", "foreground": "#ffffff",

View file

@ -83,7 +83,7 @@
"style": "diamond", "style": "diamond",
"template": " {{ if gt .Code 0 }}\uf421{{ else }}\uf469{{ end }}", "template": " {{ if gt .Code 0 }}\uf421{{ else }}\uf469{{ end }}",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -42,7 +42,7 @@
"foreground": "#C94A16", "foreground": "#C94A16",
"style": "plain", "style": "plain",
"template": "x ", "template": "x ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -100,7 +100,7 @@
}, },
"style": "powerline", "style": "powerline",
"template": "\u279c ", "template": "\u279c ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -399,7 +399,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\ue285\ue285", "template": "\ue285\ue285",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -42,8 +42,8 @@
{ {
"foreground": "#d8dee9", "foreground": "#d8dee9",
"style": "plain", "style": "plain",
"template": "<#5e81ac>[x</>{{ .Meaning }}<#5e81ac>]</>", "template": "<#5e81ac>[x</>{{ reason .Code }}<#5e81ac>]</>",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -65,7 +65,7 @@
"style": "diamond", "style": "diamond",
"template": " \ue70f ", "template": " \ue70f ",
"trailing_diamond": "\ue0c0", "trailing_diamond": "\ue0c0",
"type": "exit" "type": "status"
}, },
{ {
"background": "#2f2f2f", "background": "#2f2f2f",

View file

@ -59,7 +59,7 @@
}, },
"style": "plain", "style": "plain",
"template": "{{ if gt .Code 0 }}<p:red>({{ .Code }}) </>{{ else }}<p:green>({{ .Code }}) </>{{ end }}> ", "template": "{{ if gt .Code 0 }}<p:red>({{ .Code }}) </>{{ else }}<p:green>({{ .Code }}) </>{{ end }}> ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -55,7 +55,7 @@
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"style": "powerline", "style": "powerline",
"template": " \ue20f ", "template": " \ue20f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -32,7 +32,7 @@
"foreground": "#DCB977", "foreground": "#DCB977",
"style": "plain", "style": "plain",
"template": " \uf119 ", "template": " \uf119 ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -67,7 +67,7 @@
}, },
"style": "plain", "style": "plain",
"template": " {{ if gt .Code 0 }}<#ff0000>\uf00d</>{{ else }}<#23d18b>\uf42e</>{{ end }} ", "template": " {{ if gt .Code 0 }}<#ff0000>\uf00d</>{{ else }}<#23d18b>\uf42e</>{{ end }} ",
"type": "exit" "type": "status"
}, },
{ {
"foreground": "#bab02a", "foreground": "#bab02a",

View file

@ -79,7 +79,7 @@
}, },
"style": "plain", "style": "plain",
"template": "<transparent>\ue0b0</> \ue23a <background,transparent>\ue0b4</>", "template": "<transparent>\ue0b0</> \ue23a <background,transparent>\ue0b4</>",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -83,7 +83,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u276f ", "template": "\u276f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -94,7 +94,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u276f ", "template": "\u276f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -170,8 +170,8 @@
"always_enabled": true "always_enabled": true
}, },
"style": "powerline", "style": "powerline",
"template": " {{ if gt .Code 0 }}{{ .Meaning }}{{ else }}\u2714{{ end }} ", "template": " {{ if gt .Code 0 }}{{ reason .Code }}{{ else }}\u2714{{ end }} ",
"type": "exit" "type": "status"
}, },
{ {
"background": "#d3d7cf", "background": "#d3d7cf",

View file

@ -49,7 +49,7 @@
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"style": "powerline", "style": "powerline",
"template": " \ue20f ", "template": " \ue20f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -45,7 +45,7 @@
}, },
"style": "plain", "style": "plain",
"template": "> ", "template": "> ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -72,7 +72,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u276f ", "template": "\u276f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -32,7 +32,7 @@
"foreground": "#BF616A", "foreground": "#BF616A",
"style": "plain", "style": "plain",
"template": " \u2717", "template": " \u2717",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -264,7 +264,6 @@
"docker", "docker",
"dotnet", "dotnet",
"dart", "dart",
"exit",
"executiontime", "executiontime",
"flutter", "flutter",
"fossil", "fossil",
@ -300,6 +299,7 @@
"session", "session",
"sitecore", "sitecore",
"spotify", "spotify",
"status",
"shell", "shell",
"sysinfo", "sysinfo",
"strava", "strava",
@ -777,13 +777,13 @@
"if": { "if": {
"properties": { "properties": {
"type": { "type": {
"const": "exit" "const": "status"
} }
} }
}, },
"then": { "then": {
"title": "Exit Segment", "title": "Status Segment",
"description": "https://ohmyposh.dev/docs/segments/exit", "description": "https://ohmyposh.dev/docs/segments/status",
"properties": { "properties": {
"properties": { "properties": {
"properties": { "properties": {

View file

@ -65,7 +65,7 @@
"type": "prompt", "type": "prompt",
"segments": [ "segments": [
{ {
"type": "exit", "type": "status",
"style": "diamond", "style": "diamond",
"foreground": "#00c7fc", "foreground": "#00c7fc",
"properties": { "properties": {

View file

@ -170,7 +170,7 @@
}, },
"style": "plain", "style": "plain",
"template": " \uea9f {{ if gt .Code 0 }}{{ .Code }}{{ end }} ", "template": " \uea9f {{ if gt .Code 0 }}{{ .Code }}{{ end }} ",
"type": "exit" "type": "status"
} }
], ],
"type": "rprompt" "type": "rprompt"

View file

@ -168,7 +168,7 @@
}, },
"style": "plain", "style": "plain",
"template": " \uea9f {{ if gt .Code 0 }}{{ .Code }}{{ end }} ", "template": " \uea9f {{ if gt .Code 0 }}{{ .Code }}{{ end }} ",
"type": "exit" "type": "status"
} }
], ],
"type": "rprompt" "type": "rprompt"

View file

@ -52,7 +52,7 @@
"foreground": "#fb0207", "foreground": "#fb0207",
"style": "plain", "style": "plain",
"template": " ××× ", "template": " ××× ",
"type": "exit" "type": "status"
}, },
{ {
"foreground": "#9966ff", "foreground": "#9966ff",

View file

@ -114,7 +114,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\uf432 ", "template": "\uf432 ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -114,7 +114,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\uf432 ", "template": "\uf432 ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -7,8 +7,8 @@
{ {
"foreground": "#CB4B16", "foreground": "#CB4B16",
"style": "plain", "style": "plain",
"template": " {{ .Meaning }} ", "template": " {{ reason .Code }} ",
"type": "exit" "type": "status"
}, },
{ {
"foreground": "#CECE04", "foreground": "#CECE04",

View file

@ -41,7 +41,7 @@
"foreground": "#C94A16", "foreground": "#C94A16",
"style": "plain", "style": "plain",
"template": "x ", "template": "x ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -68,7 +68,7 @@
"template": " {{ .WorkspaceName }}{{ if .Version }} {{ .Version }}{{ end }} " "template": " {{ .WorkspaceName }}{{ if .Version }} {{ .Version }}{{ end }} "
}, },
{ {
"type": "exit", "type": "status",
"background": "#ff8080", "background": "#ff8080",
"foreground": "#ffffff", "foreground": "#ffffff",
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",

View file

@ -92,7 +92,7 @@
"powerline_symbol": "\ue0b0", "powerline_symbol": "\ue0b0",
"style": "powerline", "style": "powerline",
"template": " error ", "template": " error ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -105,7 +105,7 @@
}, },
"style": "plain", "style": "plain",
"template": "\u276f ", "template": "\u276f ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -55,7 +55,7 @@
"style": "diamond", "style": "diamond",
"template": " ", "template": " ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -20,7 +20,7 @@
"foreground": "#ff8888", "foreground": "#ff8888",
"style": "plain", "style": "plain",
"template": "{{ if gt .Code 0 }} {{ .Code }} {{ end }}", "template": "{{ if gt .Code 0 }} {{ .Code }} {{ end }}",
"type": "exit" "type": "status"
}, },
{ {
"background": "#ffcc88", "background": "#ffcc88",

View file

@ -76,7 +76,7 @@
"foreground": "#ffa5d8", "foreground": "#ffa5d8",
"style": "powerline", "style": "powerline",
"template": "[<#ffffff>\uea6c</> Error, check your command]", "template": "[<#ffffff>\uea6c</> Error, check your command]",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -56,7 +56,7 @@
} }
}, },
{ {
"type": "exit", "type": "status",
"style": "plain", "style": "plain",
"foreground": "p:terminal-red", "foreground": "p:terminal-red",
"template": " \uf00d" "template": " \uf00d"

View file

@ -109,7 +109,7 @@
}, },
"style": "plain", "style": "plain",
"template": " \u007E ", "template": " \u007E ",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

View file

@ -74,7 +74,7 @@
"style": "diamond", "style": "diamond",
"template": " \ueb05{{ if gt .Code 0 }} {{.Code}}{{ end }} ", "template": " \ueb05{{ if gt .Code 0 }} {{.Code}}{{ end }} ",
"trailing_diamond": "\ue0b4", "trailing_diamond": "\ue0b4",
"type": "exit" "type": "status"
} }
], ],
"type": "prompt" "type": "prompt"

Some files were not shown because too many files have changed in this diff Show more