创建在后台启动的 emacs 别名?
我在 bash 中有一个别名,如果 emacs 守护进程已经在运行,则该别名运行 emacsclient,否则启动 emacs。但是,如果启动了新的 emacs 实例,我可以让它在后台运行,以便我仍然可以使用该终端(或关闭它)吗?在我的 bash 配置文件中,
alias ec="/usr/bin/emacsclient.emacs-snapshot -n -c -a /usr/bin/emacs-snapshot"
我可能在终端并输入
$ ec newfile
If emacs daemon is not already running, is there a alias I can create 使上面的行相当于
$ emacs newfile &
而不是
$ emacs newfile
(我还应该提到我是使用 Linux Ubuntu 并将 emacs-snapshot 分配给别名“emacs”)。
非常感谢!
I have an alias in bash that runs emacsclient if emacs daemon is already running and start emacs otherwise. However, in the event that a fresh instance of emacs is fired up, can I make it run in the background so I can still use that terminal (or close it)? In my bash profile, I have
alias ec="/usr/bin/emacsclient.emacs-snapshot -n -c -a /usr/bin/emacs-snapshot"
And I might be at the terminal and type
$ ec newfile
If emacs daemon is not already running, is there an alias I can create to make the line above do the equivalent of
$ emacs newfile &
instead of
$ emacs newfile
(I should also mention that I am using Linux Ubuntu and emacs-snapshot is assigned to the alias, 'emacs').
Thanks much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要直接调用
/usr/bin/emacs-snapshot
,而是编写一个在后台调用/usr/bin/emacs-snapshot
的脚本,然后返回:然后调用以普通方式编写脚本;它将启动后台 emacs 进程并立即返回。
如果你想变得更奇特,你可以使用
/bin/bash
并在esac
之后disown
进程(使用$ 获取 pid !
)。Instead of calling
/usr/bin/emacs-snapshot
directly, write a script that calls/usr/bin/emacs-snapshot
in the background and then returns:Then you call the script in the ordinary way; it will launch a background emacs process and return immediately.
If you want to get fancy you can use
/bin/bash
anddisown
the process after theesac
(get the pid with$!
).虽然这不是您问题的直接答案,但这是“启动 emacs deamon 或以其他方式运行 emacsclient”的更优雅的方式。创建以下别名:
alias emacs=emacsclient -c -a ""
。从man emacsclient
开始:While this is not the direct answer to your question, this is the more elegant way to "start emacs deamon or run emacsclient otherwise". Create the following alias:
alias emacs=emacsclient -c -a ""
. As ofman emacsclient
: