1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-10-01 06:29:06 +00:00
starship/src/init/starship.elv
David Knaack 6ca911b9fe
fix(elvish): use $pwd for logical-path (#3534)
The `$PWD` environment variable used by starship is not updated on startup by `elvish`. `elvish` also provides a separate `$pwd` variable that does get updated and seems to be be a better indicator for the current logical path.
2022-01-28 21:48:10 +01:00

34 lines
1.0 KiB
Plaintext

set-env STARSHIP_SHELL "elvish"
set-env STARSHIP_SESSION_KEY (to-string (randint 10000000000000 10000000000000000))
# 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 = {
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
::STARSHIP:: prompt --jobs=$num-bg-jobs --cmd-duration=$cmd-duration --status=$cmd-status-code --logical-path=$pwd
}
set edit:rprompt = {
var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000))
::STARSHIP:: prompt --right --jobs=$num-bg-jobs --cmd-duration=$cmd-duration --status=$cmd-status-code --logical-path=$pwd
}