Open cjfullerton opened 1 year ago
Looks like there are two methods to do this:
~/.bashrc
or source ~/.bashrc
preserves current shell and augments with any additions made to .bashrc
. This means (for example) that removing lines that add folders to the path will not remove them from the current path.
exec bash
, or, more robustly, exec "$BASH"
. This replaces the current shell with a new one, wiping the slate clean.
The first of these options sounds preferable to use in the script to avoid clearing any parameters the script is using.
This seems to work, although have had to use an alternate solution for zsh users.
Script runs in bash, so if user has zsh as default and .zshrc is modified, cannot source .zshrc within script.
Instead, just before exit if .zshrc exists the script runs exec .zshrc
.
This could cause some issues if user has bash as default and .zshrc exists - they will find themselves in a zsh shell unexpectedly.
Actually, might have to do something similar for bash at the end of the script - the script runs in its own shell, so any changes to path aren't reflected when the script finishes.
Have tried several formulations of this for bash, but none have worked so far. May need to advise user to run source ~/.bashrc
manually?
Retitled as aliases require a shell restart under Powershell too.
Assume this is possible:
If script adds hpcflow/links folder to path, want to reload
.bashrc
so path is updated when script is finished and user can instantly run the installed app.