-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexecutable_dot_oh-my-posh.nu
68 lines (57 loc) · 2.08 KB
/
executable_dot_oh-my-posh.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# make sure we have the right prompt render correctly
if ($env.config? | is-not-empty) {
$env.config = ($env.config | upsert render_right_prompt_on_last_line true)
}
$env.POWERLINE_COMMAND = 'oh-my-posh'
$env.POSH_THEME = (echo $"($env.HOME)/.nheer.omp.yaml")
$env.PROMPT_INDICATOR = ""
$env.POSH_SESSION_ID = (echo "b270e650-2ca0-41e9-b171-ff2c42874da5")
$env.POSH_SHELL = "nu"
$env.POSH_SHELL_VERSION = (version | get version)
# disable all known python virtual environment prompts
$env.VIRTUAL_ENV_DISABLE_PROMPT = 1
$env.PYENV_VIRTUALENV_DISABLE_PROMPT = 1
let _omp_executable: string = (echo "/opt/homebrew/bin/oh-my-posh")
# PROMPTS
def --wrapped _omp_get_prompt [
type: string,
...args: string
] {
mut execution_time = -1
mut no_status = true
# 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.
if $env.CMD_DURATION_MS != '0823' {
$execution_time = $env.CMD_DURATION_MS
$no_status = false
}
(
^$_omp_executable print $type
--save-cache
--shell=nu
$"--shell-version=($env.POSH_SHELL_VERSION)"
$"--status=($env.LAST_EXIT_CODE)"
$"--no-status=($no_status)"
$"--execution-time=($execution_time)"
$"--terminal-width=((term size).columns)"
...$args
)
}
$env.PROMPT_MULTILINE_INDICATOR = (
^$_omp_executable print secondary
--shell=nu
$"--shell-version=($env.POSH_SHELL_VERSION)"
)
$env.PROMPT_COMMAND = {||
# hack to set the cursor line to 1 when the user clears the screen
# this obviously isn't bulletproof, but it's a start
mut clear = false
if $nu.history-enabled {
$clear = (history | is-empty) or ((history | last 1 | get 0.command) == "clear")
}
if ($env.SET_POSHCONTEXT? | is-not-empty) {
do --env $env.SET_POSHCONTEXT
}
_omp_get_prompt primary $"--cleared=($clear)"
}
$env.PROMPT_COMMAND_RIGHT = {|| _omp_get_prompt right }