I am writing a bash function that will run some commands to setup the environment and then leave the user at the prompt.
I can run
bash -c 'ls'
To execute ls
in bash.
I can also do
bash -c 'ls ; exec bash'
To execute ls
, and then leave a bash prompt open.
However, I want to source a file and setup some aliases, functions, and environment variables and then leave the prompt open, so something like this:
bash -c 'source env.sh ; exec bash'
Of course, this doesn't work because subshells will not inherit aliases or functions. Is there a way around this problem? I'd prefer to still have the user's .bashrc
be sourced, and not use the --init-file
option.
--init-file
option?bash
and sourcing some files). Making a new file seemed excessive when I only needed to execute around 5 lines