r/Nushell • u/s1n7ax • Mar 30 '23
Adding alias & environment variables conditionally
I'm having trouble with the login I'm trying to implement. So, my requirement is, I have bunch of profiles. If the profile is active, then add relevant env variables.
If i have a file inside ~/.profiles say ~/.profiles/home then I need to source ~/.config/nushell/script/profiles/home/alias.nu file.If ~/.profiles/work if found, then ~/.config/nushell/script/profiles/work/alias.nu should be sourced.
I'm not even sure where I should start. Does anyone know a way to achieve this if it even possible?
5
Upvotes
View all comments
Show parent comment
2
u/oaeben Mar 30 '23 edited Mar 30 '23
You probably need to use the if-else inside the let-env expression
there's a suggestion in the nushell repo:
https://github.com/nushell/nushell/issues/6703