当我运行shell命令时,有没有办法让我的emacs识别我的bash别名和自定义函数? [英] Is there a way to get my emacs to recognize my bash aliases and custom functions when I run a shell command?

查看:128
本文介绍了当我运行shell命令时,有没有办法让我的emacs识别我的bash别名和自定义函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的shell环境中,我有别名和自定义函数。当我在一个emacs的实例(我总是使用emacs -nw)和我执行一个shell命令(M-x!)我不能使用它们。这是有道理的,因为我想象它启动它自己的subshel​​l来做这些..但是有一种方式(也许在我的.emacs),以使其工作?也许即使在执行任何shell命令之前默认采用环境?

解决方案

以下是我对我的看法是一个相关的问题:



我认为 Mx shell命令 Mx 通过调用进程在下面的shell中编译执行命令。尝试以下的.emacs(或只是评估):

 (setq shell-file-名称bash)
(setq shell-command-switch-ic)

我注意到,在评估上述之后,.bashrc别名被选择以供 Mx shell命令和 Mx 编译使用,即



Mx 编译 RET your_alias RET



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



来源


In my shell environment I have aliases and custom functions. When I am in an instance of emacs (I always use emacs -nw) and I execute a shell command (M-x !) I cannot use them. This makes sense since I imagine it launches it's own subshell to do these..but is there a way (maybe in my .emacs) to get this to work? Perhaps even if it involved sourcing an environment by default before executing any shell command given?

解决方案

Below are my comments about what I think was a related question:

I think both M-x shell-command and M-x compile execute commands in an inferior shell via call-process. Try the following in your .emacs (or just evaluate):

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

I notice that after evaluation of the above, .bashrc aliases are picked up for use by both M-x shell-command and M-x compile, i.e

M-x compile RET your_alias RET

should then work.

My environment: Emacs 24.1 (pretest rc1), OSX 10.7.3

Source

这篇关于当我运行shell命令时,有没有办法让我的emacs识别我的bash别名和自定义函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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