shell - 我怎样才能检测到 emacs-server 正在从 shell 提示符运行?

标签 shell bash

我想让我的 .bashrc 检测运行 emacsclient 是否可以代替运行 emacs。基本上:

if emacs_server_is_running; then
    EDITOR=emacsclient
    VISUAL=emacsclient
else
    EDITOR=emacs
    VISUAL=emacs
fi

我应该在 emacs_server_is_running 函数中放入什么来实现这个目标?

最佳答案

你太难了。来自 emacsclient(1) 手册页:

-a, --alternate-editor=EDITOR if the Emacs server is not running, run the specified editor instead. This can also be specified via the `ALTERNATE_EDITOR' environment variable. If the value of EDITOR is the empty string, then Emacs is started in daemon mode and emacsclient will try to connect to it.

关于shell - 我怎样才能检测到 emacs-server 正在从 shell 提示符运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1510481/

相关文章:

linux - Shell 代码在控制台中有效,但在脚本中无效

linux - 在 Alpine Docker 容器中运行 OpenSSH

r - 指定在 R 中使用哪个 shell

bash - 查找 - 抑制 "No such file or directory"错误

bash - 我可以更改 `nohup.out` 的名称吗?

bash - 需要使用 shell 脚本从文件中替换行的特定部分

linux - Sh 脚本帮助 - 试卷评分

bash - 在 shell 脚本中传递 CMAKE_CXX_FLAGS

bash - 找不到 `msbuild` 命令,但 `msbuild.exe` 工作正常

macos - 执行后退出终端