nushell config
This commit is contained in:
56
nushell/modules/pj_prompt.nu
Normal file
56
nushell/modules/pj_prompt.nu
Normal file
@@ -0,0 +1,56 @@
|
||||
export def --env "pj starship config" [name: string] {
|
||||
if (which ^starship | is-empty) {
|
||||
echo "starship is not installed." | warn
|
||||
return
|
||||
}
|
||||
$env.starship_config = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_($name).toml")
|
||||
}
|
||||
|
||||
export def --env "pj starship list" [] {
|
||||
if (which ^starship | is-empty) {
|
||||
echo "starship is not installed." | warn
|
||||
return
|
||||
}
|
||||
ls ($env.NU_POLYJUICE_PATH | path join ".." "starship") -s | get name | parse -r '^(starship_(?<name>.*).toml)$' | get name
|
||||
}
|
||||
|
||||
export-env {
|
||||
if (which ^starship | is-not-empty) {
|
||||
$env.STARSHIP_SHELL = "nu"
|
||||
load-env {
|
||||
STARSHIP_SESSION_KEY: (random chars -l 16)
|
||||
PROMPT_MULTILINE_INDICATOR: (
|
||||
^'starship' prompt --continuation
|
||||
)
|
||||
|
||||
# Does not play well with default character module.
|
||||
# TODO: Also Use starship vi mode indicators?
|
||||
PROMPT_INDICATOR: ""
|
||||
|
||||
PROMPT_COMMAND: {||
|
||||
# jobs are not supported
|
||||
(
|
||||
^'starship' prompt
|
||||
--cmd-duration $env.CMD_DURATION_MS
|
||||
$"--status=($env.LAST_EXIT_CODE)"
|
||||
--terminal-width (term size).columns
|
||||
)
|
||||
}
|
||||
|
||||
config: ($env.config? | default {} | merge {
|
||||
render_right_prompt_on_last_line: true
|
||||
})
|
||||
|
||||
PROMPT_COMMAND_RIGHT: {||
|
||||
(
|
||||
^'starship' prompt
|
||||
--right
|
||||
--cmd-duration $env.CMD_DURATION_MS
|
||||
$"--status=($env.LAST_EXIT_CODE)"
|
||||
--terminal-width (term size).columns
|
||||
)
|
||||
}
|
||||
}
|
||||
$env.starship_config = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_default.toml")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user