I was working with a program and it deleted my .bash_profile, which I unfortunately haven't backed up for several months. I however, have one terminal open that I am not going to close which has the file loaded in.
Is there any possible way I can "export" the loaded bash aliases etc from the current terminal?
bash_profile is read and executed when Bash is invoked as an interactive login shell, while . bashrc is executed for an interactive non-login shell. Use . bash_profile to run commands that should run only once, such as customizing the $PATH environment variable .
bash_profile is used for customizing the user configuration settings. This file is located in the home directory and is mostly hidden. The . bash_profile files are considered as configuration scripts.
Check if the bash_profile is visible there or not. If not, press Command + Shift + . and bash_profile will be visible. Select the bash_profile and press Command + Delete to delete the file.
bash_profile and . bashrc are specific to bash , whereas . profile is read by many shells in the absence of their own shell-specific config files.
If the .bash_profile file does not exist, you can try to run the following command: instead of .bash_profile. You can find more information about bashrc. function reload! () { echo "Reloading bash profile...!" source ~/.bash_profile echo "Reloaded!!!" } No, its on yr preference.
Reloading the .bash_profile. We can reload a .bash_profile directly from the current terminal without opening a new one, by using the following command.. ~/.bash_profile. The dot (.) operator execute commands from the file in the current environment. Similarly, you can also use the source command.
How can I reload file .bash_profile from the command line? I can get the shell to recognize changes to .bash_profile by exiting and logging back in, but I would like to be able to do it on demand. Simply type source ~/.bash_profile. Alternatively, if you like saving keystrokes, you can type . ~/.bash_profile.
If you like to restore it, you could try to get it from your TimeMachine backup (if present) You can try to recover it using TestDisk. to at least recover your PATH and aliases, which you can paste in your new profile file. Unfortunately this is what revision control is for.
alias > my_aliases
can give you some aliases back, but if you have hundreds, you probably want to use comm(1)
to identify which ones are in another file.
declare
will dump out all variables and functions in your current shell. (So will set
.)
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