diff --git a/README.md b/README.md index 195591f2..c728fecc 100644 --- a/README.md +++ b/README.md @@ -258,7 +258,7 @@ shown below. Can't see yours? Have a look at the [extra platform instructions](h #### Elvish - **Warning** Only elvish v0.15 or higher is supported. + **Warning** Only elvish v0.17 or higher is supported. Add the following to the end of `~/.elvish/rc.elv`: ```sh diff --git a/docs/README.md b/docs/README.md index 4014bfc2..3c40ec15 100644 --- a/docs/README.md +++ b/docs/README.md @@ -110,7 +110,7 @@ description: Starship is the minimal, blazing fast, and extremely customizable p #### Elvish ::: warning - Only elvish v0.15 or higher is supported. + Only elvish v0.17 or higher is supported. ::: Add the following to the end of `~/.elvish/rc.elv`: diff --git a/install/install.sh b/install/install.sh index a1b06c2d..196b84f3 100755 --- a/install/install.sh +++ b/install/install.sh @@ -317,7 +317,7 @@ print_install() { # shellcheck disable=SC2088 config_file="~/.elvish/rc.elv" config_cmd="eval (starship init elvish)" - warning="${warning} Only elvish v0.15 or higher is supported." + warning="${warning} Only elvish v0.17 or higher is supported." ;; nushell ) # shellcheck disable=SC2088 diff --git a/src/init/starship.elv b/src/init/starship.elv index 1f68f1c8..d9552be8 100644 --- a/src/init/starship.elv +++ b/src/init/starship.elv @@ -1,43 +1,17 @@ set-env STARSHIP_SHELL "elvish" set-env STARSHIP_SESSION_KEY (::STARSHIP:: session) -# Define Hooks -local:cmd-start-time = 0 -local:cmd-end-time = 0 -local:cmd-duration = 0 - -fn starship-after-readline-hook [line]{ - cmd-start-time = (::STARSHIP:: time) -} - -fn starship-before-readline-hook { - cmd-end-time = (::STARSHIP:: time) - cmd-duration = (- $cmd-end-time $cmd-start-time) -} - -# 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 = { +set 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 { - ::STARSHIP:: prompt --jobs=$num-bg-jobs --cmd-duration=$cmd-duration - } + var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000)) + ::STARSHIP:: prompt --jobs=$num-bg-jobs --cmd-duration=$cmd-duration } -edit:rprompt = { +set 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 - } + var cmd-duration = (printf "%.0f" (* $edit:command-duration 1000)) + ::STARSHIP:: prompt --right --jobs=$num-bg-jobs --cmd-duration=$cmd-duration }