From 8e693571e384e7c9646d44e63ad5be8d1cfab245 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Thu, 27 Oct 2022 18:26:55 -0700 Subject: [PATCH] Create simple.nu (#309) --- prompt/simple.nu | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 prompt/simple.nu diff --git a/prompt/simple.nu b/prompt/simple.nu new file mode 100644 index 0000000..514d4af --- /dev/null +++ b/prompt/simple.nu @@ -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 +}