mirror of
https://github.com/starship/starship.git
synced 2026-06-24 02:01:36 +07:00
+25
-4
@@ -12,7 +12,28 @@ let-env PROMPT_COMMAND = {
|
||||
^::STARSHIP:: prompt $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)"
|
||||
}
|
||||
|
||||
# Not well-suited for `starship prompt --right`.
|
||||
# Built-in right prompt is equivalent to $fill$right_format in the first prompt line.
|
||||
# Thus does not play well with default `add_newline = True`.
|
||||
let-env PROMPT_COMMAND_RIGHT = {''}
|
||||
# Whether we can show right prompt on the last line
|
||||
let has_rprompt_last_line_support = (version).version >= 0.71.0
|
||||
|
||||
# Whether we have config items
|
||||
let has_config_items = (not ($env | get -i config | is-empty))
|
||||
|
||||
if $has_rprompt_last_line_support {
|
||||
let config = if $has_config_items {
|
||||
$env.config | upsert render_right_prompt_on_last_line true
|
||||
} else {
|
||||
{render_right_prompt_on_last_line: true}
|
||||
}
|
||||
{config: $config}
|
||||
} else {
|
||||
{ }
|
||||
} | load-env
|
||||
|
||||
let-env PROMPT_COMMAND_RIGHT = {
|
||||
if $has_rprompt_last_line_support {
|
||||
let width = (term size).columns
|
||||
^::STARSHIP:: prompt --right $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)"
|
||||
} else {
|
||||
''
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user