1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-06-09 11:52:21 +00:00
starship/src/init/starship.elv
David Knaack 22dc8b842e
feat: add support for elvish shell (#1725)
* feat: add support for elvish shell

* improve doc

* elvish 0.15 is out

* fix example init

* update systax for 0.15 stable

* udpate second init example too

* remove warning from swift module

* add warning to status module docs

* prefix elvish version with v
2021-02-02 12:59:55 +01:00

34 lines
852 B
Plaintext

set-env STARSHIP_SHELL "elvish"
set-env STARSHIP_SESSION_KEY (::STARSHIP:: session)
# Define Hooks
local:cmd-start-time = 0
local:cmd-end-time = 0
fn starship-after-readline-hook [line]{
cmd-start-time = (::STARSHIP:: time)
}
fn starship-before-readline-hook {
cmd-end-time = (::STARSHIP:: 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 = {
# 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-end-time $cmd-start-time)
}
}
# Get rid of default rprompt
edit:rprompt = { }