-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrc.elv
40 lines (33 loc) · 1.17 KB
/
rc.elv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# === starship ===
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]
} catch {
# 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.exe 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.exe prompt --right --jobs=$num-bg-jobs --cmd-duration=$cmd-duration --status=$cmd-status-code --logical-path=$pwd
}
# === carapace-bin ===
eval (carapace _carapace|slurp)
# === zoxide ===
eval (zoxide init elvish | slurp)