So I stupidly inadvertently destroyed ~/.bashrc. If I have open terminals with the settings that were previously there, is there a way to export the current settings back to a new .bashrc? (I've tried set > ~/.bashrc from one of said terminals with some measure of success, but wondering if there's some more magical way.)
regenerate .bashrc from current shell
bash;bashrc
One thing you can try is to recover your .bashrc from the memory of a running instance of bash. On Linux, run gcore PID to make a memory dump of a process specified by its PID. Whether this has a chance of working depends on how bash manages its memory; I haven't checked the source code to see if it's at all possible. It doesn't work for me on Debian jessie amd64.If that doesn't work, you can save your current settings, but you can't recover the way they got set, so a lot of information will be lost. If you had configuration that depends on the machine, on the terminal type, etc. then you'll only recover the settings for whatever instances of bash are still running.Print out all variables in a form that can be read back. This includes a lot of noise that you'll have to sort out. Environment variables (marked with declare -x) shouldn't be defined in your .bashrc but you might have done so anyway. Remove variables that bash sets automatically (check the manual and look at the output of declare -p in bash --norc).declare -pPrint out all functions. This includes functions not defined by you, for example functions defined by the completion system (for which you want . /etc/bash_completion instead).declare -fPrint out aliases. These can probably be used as they are.aliasPrint out shell options. Compare with the output of shopt in bash --norc to see what you changed.shoptPrint out completion settings (if you use the context-sensitive completion system). Most of these probably come from the completion system; finding the ones you've tuned might be a little difficult.completePrint out key bindings, if you've defined key bindings in your .bashrc rather than in .inputrc. This includes default bindings.bind -pFrom now on, back up all your files, and put your configuration files under version control.