Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve loaded bash profile after ~/.bash_profile deleted

Tags:

bash

shell

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?

like image 551
JonMorehouse Avatar asked Aug 26 '12 02:08

JonMorehouse


People also ask

Is Bashrc the same as bash_profile?

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 .

Where is .profile in bash?

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.

Where is my bash profile on Mac?

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.

Is bash profile same as profile?

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.

How to reload bash profile if it does not exist?

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.

How do I reload a bash profile in Ubuntu terminal?

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?

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.

How can I recover a deleted profile file?

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.


2 Answers

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.

like image 60
yingted Avatar answered Sep 28 '22 08:09

yingted


declare

will dump out all variables and functions in your current shell. (So will set.)

like image 29
ephemient Avatar answered Sep 28 '22 08:09

ephemient