mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
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:
parent
2da3722521
commit
f47da9592f
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -40,7 +40,7 @@
|
|||
"print",
|
||||
"transient",
|
||||
"--shell=pwsh",
|
||||
"--error=1"
|
||||
"--status=1"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -12,7 +12,8 @@ import (
|
|||
var (
|
||||
pwd string
|
||||
pswd string
|
||||
exitCode int
|
||||
status int
|
||||
pipestatus string
|
||||
timing float64
|
||||
stackCount int
|
||||
terminalWidth int
|
||||
|
@ -22,7 +23,7 @@ var (
|
|||
command string
|
||||
shellVersion string
|
||||
plain bool
|
||||
noExitCode bool
|
||||
noStatus bool
|
||||
)
|
||||
|
||||
// printCmd represents the prompt command
|
||||
|
@ -51,7 +52,8 @@ var printCmd = &cobra.Command{
|
|||
Config: config,
|
||||
PWD: pwd,
|
||||
PSWD: pswd,
|
||||
ErrorCode: exitCode,
|
||||
ErrorCode: status,
|
||||
PipeStatus: pipestatus,
|
||||
ExecutionTime: timing,
|
||||
StackCount: stackCount,
|
||||
TerminalWidth: terminalWidth,
|
||||
|
@ -61,7 +63,7 @@ var printCmd = &cobra.Command{
|
|||
Plain: plain,
|
||||
Primary: args[0] == "primary",
|
||||
Cleared: cleared,
|
||||
NoExitCode: noExitCode,
|
||||
NoExitCode: noStatus,
|
||||
}
|
||||
|
||||
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(&shellName, "shell", "", "the shell to print for")
|
||||
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().IntVarP(&stackCount, "stack-count", "s", 0, "number of locations on the stack")
|
||||
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().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(&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)
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ func (segment *Segment) migrationOne(env platform.Environment) {
|
|||
segment.migrateColorOverride("version_mismatch_color", "{{ if .Mismatch }}%s{{ end }}", background)
|
||||
}
|
||||
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") {
|
||||
template = strings.ReplaceAll(template, ".Text", ".Meaning")
|
||||
segment.Properties[segmentTemplate] = template
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/jandedobbeleer/oh-my-posh/src/segments"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
mock2 "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -326,7 +327,9 @@ func TestSegmentTemplateMigration(t *testing.T) {
|
|||
Type: tc.Type,
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ const (
|
|||
|
||||
func (e *Engine) Primary() string {
|
||||
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.PromptStart())
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ func (e *Engine) ExtraPrompt(promptType ExtraPromptType) string {
|
|||
}
|
||||
|
||||
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.PromptStart())
|
||||
}
|
||||
|
|
|
@ -217,6 +217,8 @@ const (
|
|||
SITECORE SegmentType = "sitecore"
|
||||
// SPOTIFY writes the SPOTIFY status for Mac
|
||||
SPOTIFY SegmentType = "spotify"
|
||||
// STATUS writes the last know command status
|
||||
STATUS SegmentType = "status"
|
||||
// STRAVA is a sports activity tracker
|
||||
STRAVA SegmentType = "strava"
|
||||
// Subversion segment
|
||||
|
@ -275,7 +277,7 @@ var Segments = map[SegmentType]func() SegmentWriter{
|
|||
DOTNET: func() SegmentWriter { return &segments.Dotnet{} },
|
||||
EXECUTIONTIME: func() SegmentWriter { return &segments.Executiontime{} },
|
||||
ELIXIR: func() SegmentWriter { return &segments.Elixir{} },
|
||||
EXIT: func() SegmentWriter { return &segments.Exit{} },
|
||||
EXIT: func() SegmentWriter { return &segments.Status{} },
|
||||
FLUTTER: func() SegmentWriter { return &segments.Flutter{} },
|
||||
FOSSIL: func() SegmentWriter { return &segments.Fossil{} },
|
||||
GCP: func() SegmentWriter { return &segments.Gcp{} },
|
||||
|
@ -314,6 +316,7 @@ var Segments = map[SegmentType]func() SegmentWriter{
|
|||
SHELL: func() SegmentWriter { return &segments.Shell{} },
|
||||
SITECORE: func() SegmentWriter { return &segments.Sitecore{} },
|
||||
SPOTIFY: func() SegmentWriter { return &segments.Spotify{} },
|
||||
STATUS: func() SegmentWriter { return &segments.Status{} },
|
||||
STRAVA: func() SegmentWriter { return &segments.Strava{} },
|
||||
SVN: func() SegmentWriter { return &segments.Svn{} },
|
||||
SWIFT: func() SegmentWriter { return &segments.Swift{} },
|
||||
|
|
|
@ -105,9 +105,9 @@ func (env *MockedEnvironment) RunShellCommand(shell, command string) string {
|
|||
return args.String(0)
|
||||
}
|
||||
|
||||
func (env *MockedEnvironment) ErrorCode() int {
|
||||
func (env *MockedEnvironment) StatusCodes() (int, string) {
|
||||
args := env.Called()
|
||||
return args.Int(0)
|
||||
return args.Int(0), args.String(1)
|
||||
}
|
||||
|
||||
func (env *MockedEnvironment) ExecutionTime() float64 {
|
||||
|
|
|
@ -52,6 +52,7 @@ var (
|
|||
|
||||
type Flags struct {
|
||||
ErrorCode int
|
||||
PipeStatus string
|
||||
Config string
|
||||
Shell string
|
||||
ShellVersion string
|
||||
|
@ -215,7 +216,7 @@ type Environment interface {
|
|||
GOOS() string
|
||||
Shell() string
|
||||
Platform() string
|
||||
ErrorCode() int
|
||||
StatusCodes() (int, string)
|
||||
PathSeparator() string
|
||||
HasFiles(pattern string) bool
|
||||
HasFilesInDir(dir, pattern string) bool
|
||||
|
@ -611,9 +612,9 @@ func (env *Shell) HasCommand(command string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (env *Shell) ErrorCode() int {
|
||||
func (env *Shell) StatusCodes() (int, string) {
|
||||
defer env.Trace(time.Now())
|
||||
return env.CmdFlags.ErrorCode
|
||||
return env.CmdFlags.ErrorCode, env.CmdFlags.PipeStatus
|
||||
}
|
||||
|
||||
func (env *Shell) ExecutionTime() float64 {
|
||||
|
@ -798,7 +799,7 @@ func (env *Shell) TemplateCache() *TemplateCache {
|
|||
tmplCache.Root = env.Root()
|
||||
tmplCache.Shell = env.Shell()
|
||||
tmplCache.ShellVersion = env.CmdFlags.ShellVersion
|
||||
tmplCache.Code = env.ErrorCode()
|
||||
tmplCache.Code, _ = env.StatusCodes()
|
||||
tmplCache.WSL = env.IsWsl()
|
||||
tmplCache.Segments = make(map[string]interface{})
|
||||
tmplCache.PromptCount = env.CmdFlags.PromptCount
|
||||
|
|
|
@ -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
109
src/segments/status.go
Normal 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
106
src/segments/status_test.go
Normal 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)
|
||||
}
|
||||
}
|
|
@ -46,19 +46,26 @@ function set_poshcontext() {
|
|||
}
|
||||
|
||||
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_elapsed=-1
|
||||
local no_exit_code="true"
|
||||
|
||||
if [[ -n "$omp_start_time" ]]; then
|
||||
local omp_now=$(::OMP:: get millis --shell=bash)
|
||||
omp_elapsed=$((omp_now-omp_start_time))
|
||||
omp_start_time=""
|
||||
no_exit_code="false"
|
||||
fi
|
||||
|
||||
set_poshcontext
|
||||
_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
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,12 @@ set edit:after-command = [ $@edit:after-command $posh-after-command-hook~ ]
|
|||
|
||||
set edit:prompt = {
|
||||
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 = {
|
||||
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') {
|
||||
|
|
|
@ -14,15 +14,17 @@ end
|
|||
|
||||
function fish_prompt
|
||||
set --local omp_status_cache_temp $status
|
||||
set --local omp_pipestatus_cache_temp $pipestatus
|
||||
# clear from cursor to end of screen as
|
||||
# commandline --function repaint does not do this
|
||||
# see https://github.com/fish-shell/fish-shell/issues/8418
|
||||
printf \e\[0J
|
||||
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
|
||||
end
|
||||
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_duration "$CMD_DURATION$cmd_duration"
|
||||
set --global omp_no_exit_code false
|
||||
|
@ -49,7 +51,7 @@ function fish_prompt
|
|||
if test "$last_command" = "clear"
|
||||
set omp_cleared true
|
||||
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
|
||||
|
||||
function fish_right_prompt
|
||||
|
@ -66,7 +68,7 @@ function fish_right_prompt
|
|||
return
|
||||
end
|
||||
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
|
||||
|
||||
function postexec_omp --on-event fish_postexec
|
||||
|
@ -104,7 +106,7 @@ function _render_tooltip
|
|||
if not test -n "$omp_tooltip_command"
|
||||
return
|
||||
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 test "$has_omp_tooltip" = "true"
|
||||
commandline --function repaint
|
||||
|
|
|
@ -142,14 +142,14 @@ end
|
|||
|
||||
local function error_level_option()
|
||||
if os.geterrorlevel ~= nil and settings.get("cmd.get_errorlevel") then
|
||||
return "--error "..os.geterrorlevel()
|
||||
return "--status "..os.geterrorlevel()
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
local function no_exit_code_option()
|
||||
if no_exit_code then
|
||||
return "--no-exit-code"
|
||||
return "--no-status"
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ export-env {
|
|||
let clear = (history | last 1 | get 0.command) == "clear"
|
||||
|
||||
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)"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
}
|
||||
$position = $host.UI.RawUI.CursorPosition
|
||||
$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
|
||||
if ($standardOut -eq '') {
|
||||
return
|
||||
|
@ -420,7 +420,7 @@ Example:
|
|||
$env:POSH_CURSOR_LINE = $Host.UI.RawUI.CursorPosition.Y + 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
|
||||
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
|
||||
|
|
|
@ -13,11 +13,11 @@ def get_command_context():
|
|||
|
||||
def posh_primary():
|
||||
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():
|
||||
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
|
||||
|
|
|
@ -4,7 +4,7 @@ setenv POSH_SHELL_VERSION "";
|
|||
|
||||
set USER_PRECMD = "`alias precmd`";
|
||||
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`';
|
||||
alias precmd "$POSH_PRECMD;$USER_PRECMD";
|
||||
alias postcmd "$POSH_POSTCMD;$USER_POSTCMD";
|
||||
|
|
|
@ -43,7 +43,7 @@ function prompt_ohmyposh_preexec() {
|
|||
}
|
||||
|
||||
function prompt_ohmyposh_precmd() {
|
||||
omp_last_error=$?
|
||||
omp_last_error=$? pipeStatus=(${pipestatus[@]})
|
||||
omp_stack_count=${#dirstack[@]}
|
||||
omp_elapsed=-1
|
||||
no_exit_code="true"
|
||||
|
@ -56,7 +56,7 @@ function prompt_ohmyposh_precmd() {
|
|||
export POSH_PROMPT_COUNT=$count
|
||||
set_poshcontext
|
||||
_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
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ function _posh-tooltip() {
|
|||
if [[ -z "$tip" ]]; then
|
||||
return
|
||||
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
|
||||
if [[ -z "$tooltip" ]]; then
|
||||
return
|
||||
|
@ -114,7 +114,7 @@ function _posh-zle-line-init() {
|
|||
local -i ret=$?
|
||||
(( $+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
|
||||
|
||||
# If we received EOT, we exit the shell
|
||||
|
|
|
@ -16,6 +16,7 @@ func funcMap() template.FuncMap {
|
|||
"replaceP": replaceP,
|
||||
"gt": gt,
|
||||
"lt": lt,
|
||||
"reason": GetReasonFromStatus,
|
||||
}
|
||||
for key, fun := range sprig.TxtFuncMap() {
|
||||
if _, ok := funcMap[key]; !ok {
|
||||
|
|
|
@ -1,37 +1,8 @@
|
|||
package segments
|
||||
package template
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
import "strconv"
|
||||
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/platform"
|
||||
"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
|
||||
func GetReasonFromStatus(code int) string { //nolint: gocyclo
|
||||
switch code {
|
||||
case 1:
|
||||
return "ERROR"
|
|
@ -208,6 +208,8 @@ func (f *fields) init(data interface{}) {
|
|||
for key := range m {
|
||||
(*f)[key] = true
|
||||
}
|
||||
case reflect.Ptr:
|
||||
f.init(reflect.ValueOf(data).Elem().Interface())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
"style": "diamond",
|
||||
"template": "<parentBackground>\ue0b0</> \ue23a ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
"style": "diamond",
|
||||
"template": "<parentBackground>\ue0b0</> \ue23a ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": " \ue286 ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
{
|
||||
"foreground": "#ffffff",
|
||||
"style": "plain",
|
||||
"template": "{{ .Meaning }}\u274c ",
|
||||
"type": "exit"
|
||||
"template": "{{ reason .Code }}\u274c ",
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"foreground": "#ff0000",
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
"foreground": "#ffffff",
|
||||
"powerline_symbol": "\ue0b0",
|
||||
"style": "powerline",
|
||||
"template": " {{ .Meaning }} ",
|
||||
"type": "exit"
|
||||
"template": " {{ reason .Code }} ",
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -266,7 +266,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\ue285\ueb9e ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\ue285\ueb9e ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
{
|
||||
"foreground": "#C94A16",
|
||||
"style": "plain",
|
||||
"template": "x{{ .Meaning }} ",
|
||||
"type": "exit"
|
||||
"template": "x{{ reason .Code }} ",
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -69,8 +69,8 @@
|
|||
"foreground": "#ffffff",
|
||||
"powerline_symbol": "\ue0b0",
|
||||
"style": "powerline",
|
||||
"template": "<transparent> \uf12a</> {{ .Meaning }} ",
|
||||
"type": "exit"
|
||||
"template": "<transparent> \uf12a</> {{ reason .Code }} ",
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
@ -113,7 +113,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u276f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
"style": "diamond",
|
||||
"template": " \uea6c ",
|
||||
"trailing_diamond": "\ue0b0",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
"style": "diamond",
|
||||
"template": " \ueb05 ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u2570\u2500 ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
"style": "powerline",
|
||||
"powerline_symbol": "\ue0b4",
|
||||
"template": "{{ if eq .Code 0 }} \uf004 {{ end }}",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"background": "p:error-background",
|
||||
|
@ -113,8 +113,8 @@
|
|||
"leading_diamond": " \ue0c5",
|
||||
"trailing_diamond": "\ue0c4",
|
||||
"style": "diamond",
|
||||
"template": "{{ if ne .Code 0 }} \uf00d {{ .Code }}{{ if (ne .Meaning (toString .Code)) }} - {{ .Meaning }}{{else}}{{ end }} {{ end }}",
|
||||
"type": "exit"
|
||||
"template": "{{ if ne .Code 0 }} \uf00d {{ .Code }}{{ if (ne (reason .Code) (toString .Code)) }} - {{ reason .Code }}{{else}}{{ end }} {{ end }}",
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -54,9 +54,9 @@
|
|||
"always_enabled": true
|
||||
},
|
||||
"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",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
"powerline_symbol": "\ue0b4",
|
||||
"style": "powerline",
|
||||
"template": " \ueb05 ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
{
|
||||
"foreground": "#ffffff",
|
||||
"style": "plain",
|
||||
"template": "<#CB4B16>[x</>{{ .Meaning }}<#CB4B16>]</>",
|
||||
"type": "exit"
|
||||
"template": "<#CB4B16>[x</>{{ reason .Code }}<#CB4B16>]</>",
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -53,13 +53,13 @@
|
|||
"alignment": "right",
|
||||
"segments": [
|
||||
{
|
||||
"type": "exit",
|
||||
"type": "status",
|
||||
"style": "plain",
|
||||
"foreground": "#b8ff75",
|
||||
"foreground_templates": [
|
||||
"{{ if gt .Code 0 }}#E06C75{{ end }}"
|
||||
],
|
||||
"template": " x{{ .Meaning }}"
|
||||
"template": " x{{ reason .Code }}"
|
||||
},
|
||||
{
|
||||
"foreground": "#b8ff75",
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
{
|
||||
"foreground": "#C94A16",
|
||||
"style": "plain",
|
||||
"template": "x{{ .Meaning }} ",
|
||||
"type": "exit"
|
||||
"template": "x{{ reason .Code }} ",
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"foreground": "#E06C75",
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
{
|
||||
"foreground": "#ffffff",
|
||||
"style": "plain",
|
||||
"template": " {{ .Meaning }}",
|
||||
"type": "exit"
|
||||
"template": " {{ reason .Code }}",
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"foreground": "#100e23",
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
"style": "diamond",
|
||||
"template": " {{ if gt .Code 0 }}\uf421 \uf119 {{ else }}\uf469 \u2665 {{ end }}",
|
||||
"trailing_diamond": "\ue0b0",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -90,8 +90,8 @@
|
|||
"foreground": "#ffffff",
|
||||
"powerline_symbol": "\ue0b0",
|
||||
"style": "powerline",
|
||||
"template": "<transparent> \uf12a</> {{ .Meaning }} ",
|
||||
"type": "exit"
|
||||
"template": "<transparent> \uf12a</> {{ reason .Code }} ",
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
@ -138,7 +138,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u276f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -64,7 +64,7 @@ blocks:
|
|||
properties:
|
||||
always_enabled: true
|
||||
style: diamond
|
||||
template: " {{ if gt .Code 0 }} {{ .Meaning }}{{ else }}{{ end }} "
|
||||
template: " {{ if gt .Code 0 }} {{ reason .Code }}{{ else }}{{ end }} "
|
||||
trailing_diamond:
|
||||
type: exit
|
||||
type: prompt
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
"style": "diamond",
|
||||
"template": " \ueb05 ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -69,8 +69,8 @@
|
|||
"always_enabled": true
|
||||
},
|
||||
"style": "plain",
|
||||
"template": "{{ if gt .Code 0 }}<parentBackground,background>\ue0b0</><transparent> \uf12a</> {{ .Meaning }} <background,transparent>\ue0b0</>{{ else }}<parentBackground,transparent>\ue0b0</>{{ end }}",
|
||||
"type": "exit"
|
||||
"template": "{{ if gt .Code 0 }}<parentBackground,background>\ue0b0</><transparent> \uf12a</> {{ reason .Code }} <background,transparent>\ue0b0</>{{ else }}<parentBackground,transparent>\ue0b0</>{{ end }}",
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
@ -113,7 +113,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u276f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -61,8 +61,8 @@
|
|||
{
|
||||
"foreground": "#CB4B16",
|
||||
"style": "plain",
|
||||
"template": " {{ .Meaning }} ",
|
||||
"type": "exit"
|
||||
"template": " {{ reason .Code }} ",
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"foreground": "#CC4B16",
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u276f",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": " ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
},
|
||||
"style": "powerline",
|
||||
"template": " \uea6c ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
"style": "diamond",
|
||||
"template": "<parentBackground>\ue0b0</> \ue23a ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -86,9 +86,9 @@
|
|||
"foreground": "#ffffff",
|
||||
"leading_diamond": "<transparent,background>\ue0b0</>",
|
||||
"style": "diamond",
|
||||
"template": "<transparent> \uf12a</> {{ .Meaning }} ",
|
||||
"template": "<transparent> \uf12a</> {{ reason .Code }} ",
|
||||
"trailing_diamond": "\ue0b0",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
"style": "diamond",
|
||||
"template": "<transparent>\ue0b0</>\ue23a ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
},
|
||||
"style": "powerline",
|
||||
"template": " {{ if gt .Code 0 }}\uf421{{ else }}\uf469 \u2665{{ end }} ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": " {{ if gt .Code 0 }}\u2a2f{{else}}\u2713{{ end }} ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
},
|
||||
"style": "diamond",
|
||||
"template": " {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"background": "#575656",
|
||||
|
@ -193,7 +193,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u276f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -77,9 +77,9 @@
|
|||
"display_exit_code": true
|
||||
},
|
||||
"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",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
"style": "diamond",
|
||||
"template": "<parentBackground>\ue0b0</> \ue23a ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
"style": "diamond",
|
||||
"template": " \uf0e7 ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -87,8 +87,8 @@
|
|||
"foreground": "#fffef9",
|
||||
"powerline_symbol": "\ue0b0",
|
||||
"style": "powerline",
|
||||
"template": " \uf12a >>{{ .Meaning }} ",
|
||||
"type": "exit"
|
||||
"template": " \uf12a >>{{ reason .Code }} ",
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"foreground": "#DCB977",
|
||||
"style": "plain",
|
||||
"template": " \uf119",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"foreground": "#66F68F",
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
},
|
||||
"style": "powerline",
|
||||
"template": " \uea6c ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": " {{ if gt .Code 0 }}\uf52f{{ else }}\uf4a7{{ end }} ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"foreground": "#ffffff",
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
"style": "diamond",
|
||||
"template": " {{ if gt .Code 0 }}\uf421{{ else }}\uf469{{ end }}",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
"foreground": "#C94A16",
|
||||
"style": "plain",
|
||||
"template": "x ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
},
|
||||
"style": "powerline",
|
||||
"template": "\u279c ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -399,7 +399,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\ue285\ue285",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
{
|
||||
"foreground": "#d8dee9",
|
||||
"style": "plain",
|
||||
"template": "<#5e81ac>[x</>{{ .Meaning }}<#5e81ac>]</>",
|
||||
"type": "exit"
|
||||
"template": "<#5e81ac>[x</>{{ reason .Code }}<#5e81ac>]</>",
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
"style": "diamond",
|
||||
"template": " \ue70f ",
|
||||
"trailing_diamond": "\ue0c0",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"background": "#2f2f2f",
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "{{ if gt .Code 0 }}<p:red>({{ .Code }}) </>{{ else }}<p:green>({{ .Code }}) </>{{ end }}> ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
"powerline_symbol": "\ue0b0",
|
||||
"style": "powerline",
|
||||
"template": " \ue20f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"foreground": "#DCB977",
|
||||
"style": "plain",
|
||||
"template": " \uf119 ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": " {{ if gt .Code 0 }}<#ff0000>\uf00d</>{{ else }}<#23d18b>\uf42e</>{{ end }} ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"foreground": "#bab02a",
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "<transparent>\ue0b0</> \ue23a <background,transparent>\ue0b4</>",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u276f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u276f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -170,8 +170,8 @@
|
|||
"always_enabled": true
|
||||
},
|
||||
"style": "powerline",
|
||||
"template": " {{ if gt .Code 0 }}{{ .Meaning }}{{ else }}\u2714{{ end }} ",
|
||||
"type": "exit"
|
||||
"template": " {{ if gt .Code 0 }}{{ reason .Code }}{{ else }}\u2714{{ end }} ",
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"background": "#d3d7cf",
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
"powerline_symbol": "\ue0b0",
|
||||
"style": "powerline",
|
||||
"template": " \ue20f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "> ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u276f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"foreground": "#BF616A",
|
||||
"style": "plain",
|
||||
"template": " \u2717",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -264,7 +264,6 @@
|
|||
"docker",
|
||||
"dotnet",
|
||||
"dart",
|
||||
"exit",
|
||||
"executiontime",
|
||||
"flutter",
|
||||
"fossil",
|
||||
|
@ -300,6 +299,7 @@
|
|||
"session",
|
||||
"sitecore",
|
||||
"spotify",
|
||||
"status",
|
||||
"shell",
|
||||
"sysinfo",
|
||||
"strava",
|
||||
|
@ -777,13 +777,13 @@
|
|||
"if": {
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "exit"
|
||||
"const": "status"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"title": "Exit Segment",
|
||||
"description": "https://ohmyposh.dev/docs/segments/exit",
|
||||
"title": "Status Segment",
|
||||
"description": "https://ohmyposh.dev/docs/segments/status",
|
||||
"properties": {
|
||||
"properties": {
|
||||
"properties": {
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
"type": "prompt",
|
||||
"segments": [
|
||||
{
|
||||
"type": "exit",
|
||||
"type": "status",
|
||||
"style": "diamond",
|
||||
"foreground": "#00c7fc",
|
||||
"properties": {
|
||||
|
|
|
@ -170,7 +170,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": " \uea9f {{ if gt .Code 0 }}{{ .Code }}{{ end }} ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "rprompt"
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": " \uea9f {{ if gt .Code 0 }}{{ .Code }}{{ end }} ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "rprompt"
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
"foreground": "#fb0207",
|
||||
"style": "plain",
|
||||
"template": " ××× ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"foreground": "#9966ff",
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\uf432 ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\uf432 ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
{
|
||||
"foreground": "#CB4B16",
|
||||
"style": "plain",
|
||||
"template": " {{ .Meaning }} ",
|
||||
"type": "exit"
|
||||
"template": " {{ reason .Code }} ",
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"foreground": "#CECE04",
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
"foreground": "#C94A16",
|
||||
"style": "plain",
|
||||
"template": "x ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
"template": " {{ .WorkspaceName }}{{ if .Version }} {{ .Version }}{{ end }} "
|
||||
},
|
||||
{
|
||||
"type": "exit",
|
||||
"type": "status",
|
||||
"background": "#ff8080",
|
||||
"foreground": "#ffffff",
|
||||
"powerline_symbol": "\ue0b0",
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
"powerline_symbol": "\ue0b0",
|
||||
"style": "powerline",
|
||||
"template": " error ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": "\u276f ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
"style": "diamond",
|
||||
"template": " ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"foreground": "#ff8888",
|
||||
"style": "plain",
|
||||
"template": "{{ if gt .Code 0 }} {{ .Code }} {{ end }}",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
},
|
||||
{
|
||||
"background": "#ffcc88",
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
"foreground": "#ffa5d8",
|
||||
"style": "powerline",
|
||||
"template": "[<#ffffff>\uea6c</> Error, check your command]",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"type": "exit",
|
||||
"type": "status",
|
||||
"style": "plain",
|
||||
"foreground": "p:terminal-red",
|
||||
"template": " \uf00d"
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
},
|
||||
"style": "plain",
|
||||
"template": " \u007E ",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
"style": "diamond",
|
||||
"template": " \ueb05{{ if gt .Code 0 }} {{.Code}}{{ end }} ",
|
||||
"trailing_diamond": "\ue0b4",
|
||||
"type": "exit"
|
||||
"type": "status"
|
||||
}
|
||||
],
|
||||
"type": "prompt"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue