This might seem like a duplicate at first sight, but bear with me for a minute.
TLDR; A quick command line way to restore the whole shell environment to the same as upon terminal startup, while not losing the print (scroll up) of the previously executed commands and their outputs.
I would really like a quick way to reset the shell environment to it's starting state, like quitting the the terminal program and starting it again (or opening a new tab). The reason that I don't want to actually quit the program and start it again is that I don't want to lose the history, ie the print of the previous commands and outputs. (Compare to clear in MATLAB, that gets rid of all variables, function definitions et.c. that you've set in that session without removing the print of previous commands and outputs.)
The usual advice people get when asking this is
However, for example, this doesn't restore $PATH to the value it has when the terminal program is first opened. I have a few lines like
in my $PATH and for every time I source, more stuff is added to my $PATH variable. Hence it is not reset to terminal startup value on
Same thing goes for any other variable set in that session that is not overwritten by some line in the
I've seen people recommend the
reset command too. However, that doesn't restore my $PATH to it's original value either. It stays the same as before the reset.
I am just using
$PATH as an example here, the question is about resetting the whole shell environment.
A quick and reliable way to reset the shell environment in the sense I describe above would be very handy when experimenting with installations and similar things. Also seeing what the
$PATH variable looks like makes me wonder what other things are not reset using
source ~/.bash_profile, and it feels unreliable to use as a reset method.
Thank you for reading this far!
Any solutions folks?