You can get a fairly complete dump of the current bash shell's environment with the bash commands set
(with no arguments, it dumps the current environment variables and functions) and alias
(similarly, dumps aliases). These may help you reconstruct a lot of the old .bashrc files.
However, you should keep in mind that these don't show the old .bashrc itself, they show its results. For example, if the default system PATH was /usr/bin:/bin:/usr/sbin:/sbin
and your old .bashrc contained
PATH="$PATH:/opt/X11/bin"
this'll just show the net result:
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
If you copy that into your new .bashrc, and the system PATH ever gets updated (e.g. to include /usr/local/bin
), your .bashrc will erase the update.
So, you shouldn't just take the output of set
and alias
and use that as your new .bashrc. But you can use them as reminders of what used to be there, and also use them to avoid e.g. having to rewrite any complex functions and such you had defined.