Hongxu Chen
Hongxu Chen

Reputation: 5360

How to make Emacs 's shell mode source my profile file?

I have defined some aliases and function snippets int some of my profile files, say, ~/.zprofile. But Emacs never reads them. There is already a topic about it. However, it's not enough:

  1. It cannot source completely .zshrc and would emit errors for compinit and the like.
  2. Seems this approach only works for environment VARIABLES.

So in shell-mode or run command in Emacs(Alt-!) the effect is still different with that in terminal(emulators).

So is there any way to deal with the problem? Thanks.

Upvotes: 9

Views: 3821

Answers (1)

Burton Samograd
Burton Samograd

Reputation: 3638

You can create a file ~/.emacs_zsh (or .emacs_bash, emacs_sh, ...) that shell-mode will use on startup. My .emacs_bash is simply:

. ~/.profile

Just be sure to put a newline at the end of the sourcing line or it won't get executed.

Upvotes: 18

Related Questions