New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prevent same entry in $env.PATH #1104
Conversation
if one extends PATH in `env.nu` and start a different shell before launching nu, one might start to collect the same path multiple times in PATH these lines construct the new value (based on home directory and the separator based on the os)
Seems like this part |
There is no benefit creating an additional env var. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding this, that can be quite handy to not have multiple times the same path in $env.PATH
for some applications 😋
just two remarks and i'd be good to go 😌
@joergsch def prepend-if-not-in [element: any]: list<any> -> list<any> {
if $element in $in { $in } else { $in | prepend $element }
}
$env.PATH = ($env.PATH | prepend-if-not-in ($nu.home-path | path join "bin")) |
Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
thanks for this new section @joergsch, let's land this 🙏 |
if one extends PATH in
env.nu
and start a different shell before launching nu, one might start to collect the same path multiple times in PATH these lines construct the new value (based on home directory and the separator based on the os)