If your terminal is still open, type
env: it will display all your environment variables. If it's a fresh install or if you never made any change, the most important variables are
PATH (this one always exist) and
LD_LIBRARY_PATH (may not exists, I'm not used to osx).
It's also a common thing to source
.bashrc in that file.
Then you can edit your
.bash_profile to add a line like this:
# Source your .bashrc
if [ -f ~/.bashrc ]; then
# Export the interesting env variables you
# displayed from env command previously
It's not a real solution since it's not a real "backup", but keep in mind that as long your terminal is open, you can know your environment variables, and main purpose of
.bash_profile is to set those variables.
Also, you may have some aliases: in your opened terminal, type
alias to display all the defined aliases. You can copy and paste the ouput as-is in your
.bash_profile. (obviously, if those aliases are available in your
.bashrc you don't need to define them in your
.bash_profile since you source the