1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-02 07:07:46 +00:00

Create simple.nu (#309)

This commit is contained in:
Alex Saveau 2022-10-27 18:26:55 -07:00 committed by GitHub
parent 3b4f9e2df4
commit 8e693571e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

22
prompt/simple.nu Normal file
View file

@ -0,0 +1,22 @@
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
}