Reputation: 815
In my .emacs
, I have some stuff that uses environment variables defined by my .bashrc
.
If I first open a terminal (which automatically reads me bashrc
), and then open emacs from there, I can get everything to work. However, if I open if from GNOME's activities, it doesn't.
Is there a way to still open emacs from GNOME's activities, but have it have the environment of by .bashrc
?
Upvotes: 3
Views: 2225
Reputation: 2376
I wrote a tutorial about this. exec-path-from-shell can significantly increase Emacs's startup time. I prefer the Doom Emacs approach: save the shell environment to a file, and load it when Emacs starts. My article shows how to do that.
Upvotes: 0
Reputation: 2115
You can use exec-path-from-shell, this will load all your shell variables as like you start emacs from terminal.
Or you can add them manually. e.g :
(defun aza-latex-path ()
(setenv "PATH" (concat "/usr/local/texlive/2018/bin/x86_64-linux:"
(getenv "PATH")))
(add-to-list 'exec-path "/usr/local/texlive/2018/bin/x86_64-linux"))
(defun aza-go-path ()
(setenv "PATH" (concat "/usr/local/go/bin:"
(getenv "PATH")))
(add-to-list 'exec-path "/usr/local/go/bin"))
Upvotes: 1
Reputation: 32426
You should probably be defining your environment variables in your ~/.profile not your ~/.bashrc so they are just loaded once during login instead of every time you launch a shell and emacs would have access to them when launched from activities by default.
But you could set a custom shortcut to launch emacs from a login shell if that's how you want to do it: e.g, => settings -> keyboard -> create custom shortcut with command like bash -l -c 'emacsclient -nc -a "" &'
to launch emacs from a login shell which should read your .bashrc.
Upvotes: 4