Skip to content

Compress $HOME into ~ in prompt#8173

Merged
fdncred merged 2 commits intonushell:mainfrom
SUPERCILEX:patch-1
Feb 22, 2023
Merged

Compress $HOME into ~ in prompt#8173
fdncred merged 2 commits intonushell:mainfrom
SUPERCILEX:patch-1

Conversation

@SUPERCILEX
Copy link
Copy Markdown
Contributor

No description provided.

@SUPERCILEX
Copy link
Copy Markdown
Contributor Author

Sidenote: the code is unnecessarily convoluted because I couldn't find a way to do prefix/suffix replacement. It'd be cool if that was a thing.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Feb 22, 2023

Sidenote: the code is unnecessarily convoluted because I couldn't find a way to do prefix/suffix replacement. It'd be cool if that was a thing.

How would prefix or suffix replacement work? Do you have an example?

@SUPERCILEX
Copy link
Copy Markdown
Contributor Author

Hmmm, I guess I was thinking trim_start_matches or strip_prefix but neither are perfect. If this were code, I think I'd write strip_prefix and then a length changed check to choose whether or not to prepend the ~. So probs nevermind then?

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 22, 2023

Codecov Report

Merging #8173 (70347c5) into main (f4a129a) will decrease coverage by 0.04%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8173      +/-   ##
==========================================
- Coverage   54.24%   54.20%   -0.04%     
==========================================
  Files         608      608              
  Lines       99081    99162      +81     
==========================================
+ Hits        53747    53753       +6     
- Misses      45334    45409      +75     
Impacted Files Coverage Δ
crates/nu-command/src/filesystem/cp.rs 14.42% <0.00%> (-3.04%) ⬇️
crates/nu-command/src/progress_bar.rs 0.00% <0.00%> (ø)
crates/nu-parser/src/parser.rs 75.74% <0.00%> (+0.08%) ⬆️
crates/nu-protocol/src/ty.rs 72.85% <0.00%> (+0.71%) ⬆️

@fdncred fdncred merged commit aba0fb0 into nushell:main Feb 22, 2023
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Feb 22, 2023

ya, strip_prefix may be str substring x..y.

Thanks for the cleanup of the script.

sholderbach pushed a commit that referenced this pull request Mar 10, 2023
This is a follow-up from #8173,
which was merged shortly after the 0.76 release. That PR changed
`default_env.nu` so that the user's home folder is displayed as `~` in
the left prompt. It did so using `get -i`.

This PR just rewrites the Nu code from
#8173 to use `try`/`catch`
instead of `-i`, which will make it easier to remove the `-i` flags from
`get` and `select` eventually (see
#8379).

I would like to merge this before the 0.77 release, so we don't end up
with lots of `env.nu` files using `get -i` out in the wild.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants