mirror of
https://github.com/Cian-H/dotfiles.git
synced 2026-01-02 15:31:56 +00:00
This change allows the dotfiles to work with chezmoi (e.g: on windows) and improves grepability with neovim/telescope
23 lines
685 B
Nu
23 lines
685 B
Nu
export def create_left_prompt [] {
|
|
let path_segment = if (is-admin) {
|
|
$"(ansi red_bold)($env.PWD)"
|
|
} else {
|
|
$"(ansi green_bold)($env.PWD)"
|
|
}
|
|
let duration_segment = do {
|
|
let duration_secs = ($env.CMD_DURATION_MS | into int) / 1000
|
|
if ($duration_secs >= 5) {
|
|
$"(ansi yellow_bold)($duration_secs | math round | into string | append "sec" | str join | into duration) "
|
|
} else {
|
|
""
|
|
}
|
|
}
|
|
let exit_code_segment = if ($env.LAST_EXIT_CODE == 0) {
|
|
""
|
|
} else {
|
|
$"(ansi red_bold)($env.LAST_EXIT_CODE) "
|
|
}
|
|
|
|
[$duration_segment, $exit_code_segment, $path_segment] | str join
|
|
}
|