How to make emacs shell execute init file automatically?
Move your initialization routines into your ~/.bashrc
file
Then add the line
source ~/.bashrc
into your ~/.bash_profile
file. See the bash man page for a detailed explanation of which startup files get loaded when. The key is the difference between an interactive and non-interactive shell, as well as the difference between a login and a non-login shell.
In general, .bash_profile
is run when logging into the system using a shell while .bashrc
is run when starting a new shell (The OS X Terminal application is an exception to this rule as it runs .bash_profile
for each new terminal instance). For more info in article form, look here.
I'm using Mac, shell-command did not execute .bashrc, nor .bash_profile, I googled a solution to have my PATH problem fixed.
put this in your .emacs:(setenv "PATH" (shell-command-to-string "source ~/.bashrc; echo -n $PATH"))
more detail, see: How to make emacs to run my ~/.bash_profile
Digging through the elisp source; seems like the shell-command in emacs just executes bash -c "command" in my case. Solution is to start emacs (emacs &) in a shell where my .profile is already executed (instead of starting emacs from the GUI menus of my windows manager).