2021-02-02 11:59:55 +00:00
|
|
|
set-env STARSHIP_SHELL "elvish"
|
|
|
|
set-env STARSHIP_SESSION_KEY (::STARSHIP:: session)
|
|
|
|
|
|
|
|
# Define Hooks
|
|
|
|
local:cmd-start-time = 0
|
|
|
|
local:cmd-end-time = 0
|
2021-09-08 19:45:27 +00:00
|
|
|
local:cmd-duration = 0
|
2021-02-02 11:59:55 +00:00
|
|
|
|
|
|
|
fn starship-after-readline-hook [line]{
|
|
|
|
cmd-start-time = (::STARSHIP:: time)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn starship-before-readline-hook {
|
|
|
|
cmd-end-time = (::STARSHIP:: time)
|
2021-09-08 19:45:27 +00:00
|
|
|
cmd-duration = (- $cmd-end-time $cmd-start-time)
|
2021-02-02 11:59:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install Hooks
|
|
|
|
edit:after-readline = [ $@edit:after-readline $starship-after-readline-hook~ ]
|
|
|
|
edit:before-readline = [ $@edit:before-readline $starship-before-readline-hook~ ]
|
|
|
|
|
|
|
|
# Install starship
|
|
|
|
edit:prompt = {
|
|
|
|
# Note:
|
|
|
|
# Elvish does not appear to support exit status codes (--status)
|
|
|
|
|
|
|
|
if (== $cmd-start-time 0) {
|
|
|
|
::STARSHIP:: prompt --jobs=$num-bg-jobs
|
|
|
|
} else {
|
2021-09-08 19:45:27 +00:00
|
|
|
::STARSHIP:: prompt --jobs=$num-bg-jobs --cmd-duration=$cmd-duration
|
2021-02-02 11:59:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-08 19:45:27 +00:00
|
|
|
edit:rprompt = {
|
|
|
|
# Note:
|
|
|
|
# Elvish does not appear to support exit status codes (--status)
|
|
|
|
|
|
|
|
if (== $cmd-start-time 0) {
|
|
|
|
::STARSHIP:: prompt --right --jobs=$num-bg-jobs
|
|
|
|
} else {
|
|
|
|
::STARSHIP:: prompt --right --jobs=$num-bg-jobs --cmd-duration=$cmd-duration
|
|
|
|
}
|
|
|
|
}
|