如何使Emacs的使用我的.bashrc文件?
我需要用我的 $ PATH
在Emacs运行一些命令。我怎样才能使Emacs的使用呢?我从Ubuntu软件仓库安装了Emacs。
I need to use my $PATH
in Emacs to run some commands. How can I make Emacs use it? I installed Emacs from Ubuntu repositories.
下面是一招的我用以确保我的GUI的Emacs总是看到相同的 $ PATH
,我得到一个shell里:
Here's a trick I use to ensure my GUI Emacs always sees the same $PATH
that I get inside a shell:
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell (replace-regexp-in-string
"[ \t\n]*$"
""
(shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq eshell-path-env path-from-shell) ; for eshell users
(setq exec-path (split-string path-from-shell path-separator))))
(when window-system (set-exec-path-from-shell-PATH))
具体而言,在OS X上,图形化的Emacs不会拿起 $ PATH
的用户的shell的定义,所以这一招可以帮助我在该平台上。
Specifically, on OS X, a graphical Emacs will not pick up the user's shell's definition of $PATH
, so this trick helps me on that platform.
更新:此code现已公布为elisp的库调用 EXEC-path-从壳并安装包都提供 MELPA 。
Update: this code has now been published as an elisp library called exec-path-from-shell and installable packages are available in MELPA.