1
0
Fork 0
This repository has been archived on 2024-01-18. You can view files and clone it, but cannot push or open issues/pull-requests.
dotnix-archive/apps/nogui/nushell/ohmyposh.nu

26 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-06-28 20:48:01 +00:00
export-env {
$env.POWERLINE_COMMAND = 'oh-my-posh'
$env.POSH_THEME = "~/.config/oh-my-posh/config.json"
$env.PROMPT_INDICATOR = ""
$env.POSH_PID = (random uuid)
2023-06-28 20:48:01 +00:00
# By default displays the right prompt on the first line
# making it annoying when you have a multiline prompt
# making the behavior different compared to other shells
$env.PROMPT_COMMAND_RIGHT = {''}
$env.NU_VERSION = (version | get version)
2023-06-28 20:48:01 +00:00
# PROMPTS
$env.PROMPT_MULTILINE_INDICATOR = (^oh-my-posh print secondary $"--config=($env.POSH_THEME)" --shell=nu $"--shell-version=($env.NU_VERSION)")
2023-06-28 20:48:01 +00:00
$env.PROMPT_COMMAND = {
2023-06-28 20:48:01 +00:00
# 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).columns | into string)
^oh-my-posh 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)"
}
}