mirror of
https://github.com/starship/starship.git
synced 2024-11-25 09:43:36 +01:00
feat(elvish): last command status (#3403)
This commit is contained in:
parent
0af31238f6
commit
500dc3ea6e
@ -447,7 +447,7 @@ look at [this example](#with-custom-error-shape).
|
||||
|
||||
::: warning
|
||||
|
||||
`error_symbol` is not supported on elvish and nu shell.
|
||||
`error_symbol` is not supported on nu shell.
|
||||
|
||||
:::
|
||||
|
||||
@ -2918,7 +2918,7 @@ To enable it, set `disabled` to `false` in your configuration file.
|
||||
:::
|
||||
|
||||
::: warning
|
||||
This module is not supported on elvish and nu shell.
|
||||
This module is not supported on nu shell.
|
||||
:::
|
||||
|
||||
### Options
|
||||
|
@ -1,17 +1,33 @@
|
||||
set-env STARSHIP_SHELL "elvish"
|
||||
set-env STARSHIP_SESSION_KEY (::STARSHIP:: session)
|
||||
|
||||
# Define Hooks
|
||||
var cmd-status-code = 0
|
||||
|
||||
fn starship-after-command-hook {|m|
|
||||
var error = $m[error]
|
||||
if (is $error $nil) {
|
||||
set cmd-status-code = 0
|
||||
} else {
|
||||
try {
|
||||
set cmd-status-code = $error[reason][exit-status]
|
||||
} except {
|
||||
# The error is from the built-in commands and they have no status code.
|
||||
set cmd-status-code = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Install Hooks
|
||||
set edit:after-command = [ $@edit:after-command $starship-after-command-hook~ ]
|
||||
|
||||
# Install starship
|
||||
set edit:prompt = {
|
||||
# Note:
|
||||
# Elvish does not appear to support exit status codes (--status)
|
||||
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
|
||||
::STARSHIP:: prompt --jobs=$num-bg-jobs --cmd-duration=$cmd-duration
|
||||
::STARSHIP:: prompt --jobs=$num-bg-jobs --cmd-duration=$cmd-duration --status $cmd-status-code
|
||||
}
|
||||
|
||||
set edit:rprompt = {
|
||||
# Note:
|
||||
# Elvish does not appear to support exit status codes (--status)
|
||||
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
|
||||
::STARSHIP:: prompt --right --jobs=$num-bg-jobs --cmd-duration=$cmd-duration
|
||||
::STARSHIP:: prompt --right --jobs=$num-bg-jobs --cmd-duration=$cmd-duration --status $cmd-status-code
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user