fix: Make log respect use_ansi_coloring setting.

- Ignore ansi coloring on logs if this setting is true.
- Add a reset after the default left prompt (before prompt character) which fixes all-red text when `use_ansi_coloring` is false.
This commit is contained in:
Stiliyan Tonev (Bark) 2024-07-24 16:29:13 +03:00
parent a88c3f48e2
commit b4a86b597d
2 changed files with 5 additions and 3 deletions

View File

@ -282,7 +282,9 @@ export def custom [
$level_prefix
}
let ansi = if ($ansi | is-empty) {
let ansi = if not $env.config.use_ansi_coloring {
""
} else if ($ansi | is-empty) {
if ($log_level not-in $valid_levels_for_defaulting) {
log-level-deduction-error "ansi" (metadata $log_level).span $log_level
}

View File

@ -11,7 +11,7 @@ def create_left_prompt [] {
let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold })
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold })
let path_segment = $"($path_color)($dir)"
let path_segment = $"($path_color)($dir)(ansi reset)"
$path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)"
}
@ -98,4 +98,4 @@ $env.NU_PLUGIN_DIRS = [
# $env.PATH = ($env.PATH | uniq)
# To load from a custom file you can use:
# source ($nu.default-config-dir | path join 'custom.nu')
# source ($nu.default-config-dir | path join 'custom.nu')