Joh*_*les 86 macos emacs command-line
如何从OSX中的命令行启动GUI Emacs?
我已经从http://emacsformacosx.com/下载并安装了Emacs .
我会接受满足以下所有条件的答案:
Dav*_*ell 111
调用以下脚本"emacs"并将其放在您的PATH某个地方:
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$@"
Run Code Online (Sandbox Code Playgroud)
这包括#2,#3和#4.
对于#1,将它放在.emacs文件中的某个位置:
(x-focus-frame nil)
Run Code Online (Sandbox Code Playgroud)
该emacsformacosx.com网站现在有一个操作方法页,这哪里是顶片段的来源.有关于运行emacsclient和挂钩Emacs 的更多信息git mergetool.
Chr*_*han 70
在shell中,将命令"emacs"别名为OSX emacs应用程序
在我的shell(运行默认的bash)中,我有以下内容(在我的.bashrc中)
alias emacs='open -a /Applications/Emacs.app $1'
Run Code Online (Sandbox Code Playgroud)
然后,在命令行上键入emacs将启动emacs应用程序.
但是,我建议你打开一份emacs,然后继续运行.如果是这种情况,并且您想要将文件加载到emacs的现有副本中,则可以通过将以下内容放在.bashrc中来使用emacsclient:
alias ec='/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'
Run Code Online (Sandbox Code Playgroud)
然后将以下内容添加到.emacs文件中以启动emacs服务器(接收emacsclient调用)
;;========================================
;; start the emacsserver that listens to emacsclient
(server-start)
Run Code Online (Sandbox Code Playgroud)
然后你可以输入
ec .bashrc
Run Code Online (Sandbox Code Playgroud)
将.bashrc的副本加载到现有的emacs会话中!
通过在后台启动Emacs,这改善了David Caldwell的答案:
#!/bin/sh
$(/Applications/Emacs.app/Contents/MacOS/Emacs "$@") &
Run Code Online (Sandbox Code Playgroud)
如其他答案所述,这涵盖#2,#3和#4.对于#1,将它放在.emacs文件中:(x-focus-frame nil).
请注意,下面就不是为我工作-它不会在命令行上指定的目录启动Emacs(例如emacs .)
# NOT RECOMMENDED
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$@" &
Run Code Online (Sandbox Code Playgroud)
小智 5
我假设你要么:
如果是这样,那么我认为这满足了原来的四个标准,再加上一个:
- emacs窗口在我的终端窗口前面打开.
它将始终打开前景(使用x-focus-frame).
- 键入"emacs"会启动GUI Emacs窗口.在该窗口中查找文件将默认查找我启动Emacs的目录.
它将以dired模式打开现有的emacs窗口.
- 当foo.txt存在时键入"emacs foo.txt"会启动加载了foo.txt的GUI Emacs窗口.
如果emacs已经运行并且有服务器,那么它将在现有窗口中打开并进入前台.
- 当foo.txt不存在时键入"emacs foo.txt"会启动一个GUI Emacs窗口,其中包含一个名为"foo.txt"的空文本缓冲区.在该缓冲区中执行^ X ^ S会将foo.txt保存在我启动Emacs的目录中.
正确.
一个额外的:
键入命令后,控制立即返回终端会话.
〜/斌/ emacs的
#!/bin/bash
EMACSPATH=/Applications/Emacs.app/Contents/MacOS
# Check if an emacs server is available
# (by checking to see if it will evaluate a lisp statement)
if ! (${EMACSPATH}/bin/emacsclient --eval "t" 2> /dev/null > /dev/null )
then
# There is no server available so,
# Start Emacs.app detached from the terminal
# and change Emac's directory to PWD
nohup ${EMACSPATH}/Emacs --chdir "${PWD}" "${@}" 2>&1 > /dev/null &
else
# The emacs server is available so use emacsclient
if [ -z "${@}" ]
then
# There are no arguments, so
# tell emacs to open a new window
${EMACSPATH}/bin/emacsclient --eval "(list-directory \"${PWD}\")"
else
# There are arguments, so
# tell emacs to open them
${EMACSPATH}/bin/emacsclient --no-wait "${@}"
fi
# Bring emacs to the foreground
${EMACSPATH}/bin/emacsclient --eval "(x-focus-frame nil)"
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
88560 次 |
| 最近记录: |