在Emacs中如何告诉shell它正在运行? [英] How do I tell a shell that it is running from within Emacs?

查看:109
本文介绍了在Emacs中如何告诉shell它正在运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,使用ansi终端代码来做一些漂亮的东西,如在终端运行时擦除行。当它从Emacs中运行时,它显然会拧紧缓冲区。



该程序有一个选项,不能使用它,所以我想要能够转动在Emacs中的shell中运行该选项。



我在Emacs中从终端或使用编译模式执行此程序作为Makefile的一部分。 / p>

所以有一种方法可以让编译模式设置一个环境变量(或类似的东西),在Makefile中很容易捕获到使用该选项的适当时机? / p>

在make命令(在任何一种情况下)手动添加一个额外的参数是我想避免的。

解决方案

EMACS在 Mx shell $ EMACS 环境变量c>会话,所以你应该检查一下(假设你不会在shell脚本中的其他地方无意中定义 EMACS

 #从登录shell 
ec在Emacs shell $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b

I have a program that uses ansi terminal codes to do fancy stuff like erasing lines when it runs in the terminal. When that is run from within Emacs, it obviously screws up the buffer.

The program has an option to not use those, so I'd like to be able to turn on that option when running in a shell within Emacs.

I execute this program as a part of a Makefile, either from the terminal or using compile-mode in Emacs.

So is there a way to have compile-mode set an environment variable (or something similar) that would be easy to catch in the Makefile to use the option when appropriate?

Manually adding an extra argument to make in the make-command (in either of the cases) is what I am trying to avoid.

解决方案

EMACS sets the $EMACS environment variable within M-x shell sessions, so you should just check for that (assuming you don't inadvertently define EMACS elsewhere within your shell scripts):

# from login shell
echo $EMACS

# within Emacs shell
bash-4.2$ echo $EMACS
t

这篇关于在Emacs中如何告诉shell它正在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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