forked from extern/nushell
FEATURE: highlight some prompt parts (#9094)
# Description - highlight directory separators with light green (for regular user) and light red (for admin) colors respectively - highlight colons and slashes in the right prompt with light magenta - underline AM/PM in the right prompt - use long options to enhance readability How it looks in MATE Terminal with Tango color theme: ![image](https://user-images.githubusercontent.com/42812113/236052908-fc80def9-9117-4b87-8ce4-321b937f3339.png) # User-Facing Changes - highlight directory separators in light green (for regular user) and red colors (for admin) - highlight colons and slashes in the right prompt with light magenta - underline AM/PM in the right prompt # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
This commit is contained in:
parent
83b1ec83c9
commit
1019acb7a3
@ -13,25 +13,26 @@ def create_left_prompt [] {
|
||||
}
|
||||
|
||||
let dir = ([
|
||||
($env.PWD | str substring 0..($home | str length) | str replace -s $home "~"),
|
||||
($env.PWD | str substring 0..($home | str length) | str replace --string $home "~"),
|
||||
($env.PWD | str substring ($home | str length)..)
|
||||
] | str join)
|
||||
|
||||
let path_segment = if (is-admin) {
|
||||
$"(ansi red_bold)($dir)"
|
||||
} else {
|
||||
$"(ansi green_bold)($dir)"
|
||||
}
|
||||
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)"
|
||||
|
||||
$path_segment
|
||||
$path_segment | str replace --all (char path_sep) $"($separator_color)/($path_color)"
|
||||
}
|
||||
|
||||
def create_right_prompt [] {
|
||||
let time_segment_color = (ansi magenta)
|
||||
|
||||
let time_segment = ([
|
||||
(ansi reset)
|
||||
(ansi magenta)
|
||||
$time_segment_color
|
||||
(date now | date format '%m/%d/%Y %r')
|
||||
] | str join)
|
||||
] | str join | str replace --all "([/:])" $"(ansi light_magenta_bold)${1}($time_segment_color)" |
|
||||
str replace --all "([AP]M)" $"(ansi light_magenta_underline)${1}")
|
||||
|
||||
let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([
|
||||
(ansi rb)
|
||||
@ -59,12 +60,12 @@ let-env PROMPT_MULTILINE_INDICATOR = {|| "::: " }
|
||||
# Note: The conversions happen *after* config.nu is loaded
|
||||
let-env ENV_CONVERSIONS = {
|
||||
"PATH": {
|
||||
from_string: { |s| $s | split row (char esep) | path expand -n }
|
||||
to_string: { |v| $v | path expand -n | str join (char esep) }
|
||||
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
|
||||
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
|
||||
}
|
||||
"Path": {
|
||||
from_string: { |s| $s | split row (char esep) | path expand -n }
|
||||
to_string: { |v| $v | path expand -n | str join (char esep) }
|
||||
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
|
||||
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user