macos - 在 Mac OS X 上使用 GUI(从 Dock)启动 Emacsclient

标签 macos emacs automator dock emacsclient

如何从 Mac OS X 上的 Dock(或者也可能从终端)启动带有 GUI 的 Emacsclient?

EmacsWiki describes如何使用 Automator 创建“Emacs from Dock”应用程序。它对我有用,但我不想启动 Emacs 而是 Emacsclient。所以,我尝试更换 /Applications/Emacs.app/Contents/MacOS/Emacs与两者 /Applications/Emacs.app/Contents/MacOS/bin/emacsclient/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c但两者都不起作用。

最佳答案

从终端
你可以找到合适的路径到emacsclient使用 type在您的 shell 中(假设 emacsclient -c 在所述 shell 中工作):

$ type emacsclient
emacsclient is /usr/local/bin/emacsclient
然后我们可以添加适当的 emacsclient 标志(详见 $ man emacsclient)来打开 GUI:/usr/local/bin/emacsclient -n -c -a ""
从 macOS GUI
推出 emacsclient从例如 Dock 或 Spotlight,它很容易使用 Automator。 Automator 内置于 macOS。
选择制作一个“Application”,然后选择“Run Shell Script”,将上述调用的修改版添加到emacsclient :/usr/local/bin/emacsclient -n -c -a "" -- "$@"然后更改“传递输入”:使用“作为参数”而不是“到标准输入”。
已添加 "$@"是放置传递给此 shell 脚本的任何可选参数的位置。在这里,这允许您传递文件名以使用 emacsclient 打开. Automator 会自动传递此文件名,例如,当您使用我们刚刚制作的应用程序单击打开文件时。这还允许您将应用程序设置为某些文件类型的默认应用程序。

从任何地方,灵活
运行上述 shell 命令的另一种方法是使用 skhd (link) . skhd学习要复杂得多,但最终可以更轻松地设置大量具有快速访问权限的 shell 命令。
例如,您可以在 macOS 的任何位置让“Ctrl-o”进入您命名的模式 open_app ,您可以从中按“e”打开 emacsclient , "d"打开 emacs --debug-init , "t"运行 emacs --adv-timers ,“f”打开 Firefox,“F”打开第二个 Firefox 配置文件,等等。

关于macos - 在 Mac OS X 上使用 GUI(从 Dock)启动 Emacsclient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39464975/

相关文章:

ios - iOS SDK 支持字符串中使用的符号的意义

emacs - adoc模式是什么意思?

emacs - 获取emacs中的处理器数量

swift - 通过 shell 脚本或 Applescript 在 Mac 上安装 SMB 的 NAS 上访问文件的 "Server"字段

bash - 如何删除 ~/Downloads 中过去 30 天内未触及、添加或打开的所有文件?

swift - NSTask 在命令中添加额外的单引号

c - mktime 和 timelocal 的区别

macos - 如何在我的新 MacBook Pro(使用 Mac OS Catalina)上安装 openMP?

windows - 如何从 Emacs 中运行 Cygwin Bash Shell?

automator - 在 Automator 工作流程中获取网络文章的标题