2021-02-02 11:59:55 +00:00
|
|
|
set-env STARSHIP_SHELL "elvish"
|
2022-01-21 07:08:14 +00:00
|
|
|
set-env STARSHIP_SESSION_KEY (to-string (randint 10000000000000 10000000000000000))
|
2021-02-02 11:59:55 +00:00
|
|
|
|
2022-01-06 21:00:38 +00:00
|
|
|
# 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~ ]
|
|
|
|
|
2021-02-02 11:59:55 +00:00
|
|
|
# Install starship
|
2021-12-30 08:49:55 +00:00
|
|
|
set edit:prompt = {
|
|
|
|
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
|
2022-01-06 21:00:38 +00:00
|
|
|
::STARSHIP:: prompt --jobs=$num-bg-jobs --cmd-duration=$cmd-duration --status $cmd-status-code
|
2021-02-02 11:59:55 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 08:49:55 +00:00
|
|
|
set edit:rprompt = {
|
|
|
|
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
|
2022-01-06 21:00:38 +00:00
|
|
|
::STARSHIP:: prompt --right --jobs=$num-bg-jobs --cmd-duration=$cmd-duration --status $cmd-status-code
|
2021-09-08 19:45:27 +00:00
|
|
|
}
|