nushell: move to modules/home
Signed-off-by: Bloxx12 <charlie@charlieroot.dev> Change-Id: I6a6a6964b332aee4de78ddbba4d16b55f6783485
This commit is contained in:
parent
71505a4629
commit
8c3ff343b0
10 changed files with 183 additions and 128 deletions
73
modules/home/nushell/prompt.nu
Normal file
73
modules/home/nushell/prompt.nu
Normal file
|
@ -0,0 +1,73 @@
|
|||
use std null_device
|
||||
|
||||
export-env {
|
||||
load-env {
|
||||
PROMPT_COMMAND: {||
|
||||
let exit_code = $env.LAST_EXIT_CODE
|
||||
mut path_segment = $env.PWD | path basename
|
||||
|
||||
let exit_code_segment = if ($exit_code == 0) {
|
||||
""
|
||||
} else {
|
||||
$"(ansi yellow)━┫(ansi red)($exit_code)(ansi yellow)┣━"
|
||||
}
|
||||
|
||||
[$"(ansi yellow)┏" $exit_code_segment "━ " $path_segment "\n"] | str join
|
||||
}
|
||||
TRANSIENT_PROMPT_COMMAND: {||
|
||||
let path_segment = $env.PWD | path basename
|
||||
|
||||
let exit_code_segment = if ($env.LAST_EXIT_CODE == 0) {
|
||||
""
|
||||
} else {
|
||||
$"(ansi yellow)━┫(ansi red)($env.LAST_EXIT_CODE)(ansi yellow)┣━"
|
||||
}
|
||||
|
||||
[$"(ansi yellow)━" $exit_code_segment "━ " $path_segment] | str join
|
||||
}
|
||||
PROMPT_INDICATOR_VI_INSERT: $"(ansi yellow)┃ "
|
||||
PROMPT_INDICATOR_VI_NORMAL: $"(ansi yellow)┋ "
|
||||
PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ "
|
||||
TRANSIENT_PROMPT_INDICATOR_VI_INSERT: " "
|
||||
TRANSIENT_PROMPT_INDICATOR_VI_NORMAL: " "
|
||||
TRANSIENT_PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ "
|
||||
|
||||
config: (
|
||||
$env.config? | default {} | merge {
|
||||
render_right_prompt_on_last_line: true
|
||||
}
|
||||
)
|
||||
|
||||
PROMPT_COMMAND_RIGHT: {||
|
||||
let jj_status = try {
|
||||
jj --quiet --color always --ignore-working-copy log --no-graph --revisions @ --template '
|
||||
separate(
|
||||
" ",
|
||||
if(empty, label("empty", "(empty)")),
|
||||
coalesce(
|
||||
surround(
|
||||
"\"",
|
||||
"\"",
|
||||
if(
|
||||
description.first_line().substr(0, 24).starts_with(description.first_line()),
|
||||
description.first_line().substr(0, 24),
|
||||
description.first_line().substr(0, 23) ++ "…"
|
||||
)
|
||||
),
|
||||
label(if(empty, "empty"), description_placeholder)
|
||||
),
|
||||
bookmarks.join(", "),
|
||||
change_id.shortest(),
|
||||
commit_id.shortest(),
|
||||
if(conflict, label("conflict", "(conflict)")),
|
||||
if(divergent, label("divergent prefix", "(divergent)")),
|
||||
if(hidden, label("hidden prefix", "(hidden)")),
|
||||
)
|
||||
' err> $null_device
|
||||
} catch {
|
||||
""
|
||||
}
|
||||
$jj_status
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue