From 2f4ebfc493a0bed343aa253ae8c73522093952d1 Mon Sep 17 00:00:00 2001 From: "L. Yeung" Date: Thu, 25 Aug 2022 12:06:05 +0800 Subject: [PATCH] fix(nu): set initial execution time to 0 --- src/shell/scripts/omp.nu | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shell/scripts/omp.nu b/src/shell/scripts/omp.nu index b30d22a4..47ffee01 100644 --- a/src/shell/scripts/omp.nu +++ b/src/shell/scripts/omp.nu @@ -11,6 +11,11 @@ let-env NU_VERSION = (version | get version) let-env PROMPT_MULTILINE_INDICATOR = (^::OMP:: print secondary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.NU_VERSION)") let-env PROMPT_COMMAND = { + # We have to do this because the initial value of `$env.CMD_DURATION_MS` is always `0823`, + # which is an official setting. + # See https://github.com/nushell/nushell/discussions/6402#discussioncomment-3466687. + let cmd_duration = if $env.CMD_DURATION_MS == "0823" { 0 } else { $env.CMD_DURATION_MS } + let width = (term size -c | get columns | into string) - ^::OMP:: print primary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.NU_VERSION)" $"--execution-time=($env.CMD_DURATION_MS)" $"--error=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" + ^::OMP:: print primary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.NU_VERSION)" $"--execution-time=($cmd_duration)" $"--error=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" }