fix(nu): set initial execution time to 0

This commit is contained in:
L. Yeung 2022-08-25 12:06:05 +08:00 committed by Jan De Dobbeleer
parent 22da6bd96d
commit 2f4ebfc493

View file

@ -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)"
}