I want to reset the shell, as I log out / log in, reloading aliases, functions, from scratch.
But don't talk about source ~/.bashrc nor . ~/.bashrc !
Why ? Because source or . just enrich the current shell, with new function(s), alias(es), and so on.
FYI, you can put this function in your bashrc :
function foo {
echo "foo";
}
Then do source ~/.bashrc or . ~/.bashrc. Yeah, foo is working. Then now, edityour .bashrc, and replace foo by bar, to have :
function bar {
echo "bar";
}
You can now type foo, and saw that the function foo is still working, despite of it doesn't exist anymore in the .bashrc file. That's the point I wanted to show.
I tryed exec bash;, but it doesn'nt load the .bashrc file. And exec bash;source ~/.bashrc; obviously doesn't work, because exec kill the current process (source is never called).
as OP wish
bash --login
NB: if you're running bash inside a terminal (xterm or alike), you need also to provide the -ls parameter (or equivalent) to the terminal. (e.g. xterm -ls )
Write the following script:
while true; do
bash
if [ $? -ne 123 ]; then
break
fi
done
Set the executable bit and set it as your shell.
Then add an alias in your ~/.bashrc:
alias resetterm="exit 123"
This requires just one extra bash process running all the time. Each time you reset, a new bash will run, and the old process will end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With