如何使Emacs的使用我的.bashrc文件? [英] How to make Emacs use my .bashrc file?

查看:384
本文介绍了如何使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.

这篇关于如何使Emacs的使用我的.bashrc文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆