Skip to content

Commit

Permalink
fix default-env after latest changes (#10052)
Browse files Browse the repository at this point in the history
# Description

default env.nu is currently broken after the changes to `str replace`.
This PR should help fix it.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# 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 -- -c "use std testing; testing run-tests --path
crates/nu-std"` 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.
-->
  • Loading branch information
sophiajt committed Aug 18, 2023
1 parent 1e3248d commit 4a1b3e2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/nu-utils/src/sample_config/default_env.nu
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def create_left_prompt [] {
}

let dir = ([
($env.PWD | str substring 0..($home | str length) | str replace --string $home "~"),
($env.PWD | str substring 0..($home | str length) | str replace $home "~"),
($env.PWD | str substring ($home | str length)..)
] | str join)

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 | str replace --all --string (char path_sep) $"($separator_color)/($path_color)"
$path_segment | str replace --all (char path_sep) $"($separator_color)/($path_color)"
}

def create_right_prompt [] {
Expand All @@ -30,8 +30,8 @@ def create_right_prompt [] {
(ansi reset)
(ansi magenta)
(date now | format date '%Y/%m/%d %r')
] | str join | str replace --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
str replace --all "([AP]M)" $"(ansi magenta_underline)${1}")
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}")

let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([
(ansi rb)
Expand Down

0 comments on commit 4a1b3e2

Please sign in to comment.