fix(elvish): upgrade shell integration for v0.17 (#3310)

This commit is contained in:
David Knaack 2021-12-30 09:49:55 +01:00 committed by GitHub
parent 52abffaec6
commit 67cddb616b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 35 deletions

View File

@ -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

View File

@ -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`:

View File

@ -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

View File

@ -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
}