bash - 当我运行 shell 命令时,有没有办法让我的 emacs 识别我的 bash 别名和自定义函数?

标签 bash shell emacs environment-variables

在我的 shell 环境中,我有别名和自定义函数。当我在 emacs 实例中(我总是使用 emacs -nw)并执行 shell 命令(M-!)时,我无法使用它们。这是有道理的,因为我想它会启动自己的子 shell 来执行这些操作......但是有没有办法(也许在我的 .emacs 中)让它工作?也许即使它涉及在执行任何给定的 shell 命令之前默认采购环境?

最佳答案

以下是我对相关问题的评论:

我认为 M-x shell-commandM-x compile 通过调用在劣质 shell 中执行命令-过程。在您的 .emacs 中尝试以下操作(或只是评估):

(setq shell-file-name "bash")
(setq shell-command-switch "-ic")

我注意到在对上述进行评估之后,.bashrc 别名被 M-x shell-command 和 M-x compile 选择使用,即

M-x 编译 RET 你的别名 RET

然后应该工作。

我的环境:Emacs 24.1 (pretest rc1), OSX 10.7.3

Source

关于bash - 当我运行 shell 命令时,有没有办法让我的 emacs 识别我的 bash 别名和自定义函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12224909/

相关文章:

bash - GNU 并行 : Argument list too long when calling function

css - 如何将 `diff`文件创建一个 "common"文件?

python - 有什么方法可以通过heredocs在python中通过ssh允许STDIN吗?

macos - 如何递归删除 UNIX 目录中的所有隐藏文件?

linux - shell 脚本 "test "命令

linux - 将输出命令保存在变量中并编写 for 循环

linux - 参数扩展

emacs - 在 Emacs 中,如何使用 elisp 脚本中的 "Other-window"?

Emacs cperl-mode make if 更符合人体工学

emacs - 在 org-mode 下,如何使代码块默认折叠?