[英]How can I invoke aquamacs from command line (OSX iterm) to open a file at a given line number?
I can invoke aquamacs
from OSX iterm
command line no problem. 我可以从OSX iterm
命令行调用aquamacs
没问题。
aquamacs myfile.txt
works as expected. aquamacs myfile.txt
按预期工作。 However passing it a line number to open at does not work: aquamacs +22 myfile.txt
also opens a new file called "+22" !! 但是传递一个行号以打开它不起作用: aquamacs +22 myfile.txt
也会打开一个名为“+22”的新文件!
How do I open a file at a particular line number? 如何在特定的行号打开文件? eg with vi
you can do vi +23 myfile.txt
to open the file at line 23 例如,使用vi
您可以执行vi +23 myfile.txt
以在第23行打开文件
I believe this is not supported by aquamacs. 我相信aquamacs不支持这一点。 The command line aquamacs can only take in one argument which is the file name, and this is why you are creating a new file called "+22" when you do aquamacs +22 myfile.txt
. 命令行aquamacs只能接受一个参数,即文件名,这就是为什么你在做aquamacs +22 myfile.txt
时创建一个名为“+22”的新文件。
As mentioned by @tingfengxia Aquamacs command line helper aquamacs
is broken. 如@ingfengxia Aquamacs命令行助手aquamacs
。 (I believe it's fixed on trunk.) (我相信它固定在行李箱上。)
aquamacs
is basically a wrapper around macOS's open
, so you can just do by hand what aquamacs
is doing. aquamacs
基本上是围绕macOS open
的包装器,因此你可以手动执行aquamacs
正在做的事情。 Assuming you have Aquamacs.app
properly installed 假设您已正确安装Aquamacs.app
open -a Aquamacs myfile.txt --args +22
will do what you want. 会做你想做的。 That is, open myfile.txt
and move the cursor to line #22. 也就是说,打开myfile.txt
并将光标移动到第22行。
Note, that because of the way that open
works, this will only work when starting a fresh Aquamacs session. 请注意,由于open
工作方式,这只适用于启动新的Aquamacs会话。 If you already have Aquamacs running, and try do 如果你已经运行了Aquamacs,那就试试吧
open -A Aquamacs my_other_file.txt --args +39
Aquamacs will open my_other_file.txt
in a new bufer, but it will not move to line #39. Aquamacs 将在新的缓冲区中打开my_other_file.txt
,但它不会移动到第39行。 Any arguments will, in fact, be ignored. 事实上, 任何论点都会被忽略。
I should add that Aquamacs does come with an associated emacsclient
that works just fine. 我应该补充一点,Aquamacs确实附带了一个相关的emacsclient
,工作得很好。 Provided you've run server-start
in your Aquamacs session (either via your init file, or manually) you can then do 如果您已经在Aquamacs会话中运行server-start
(通过init文件或手动),那么您可以这样做
/Applications/Aquamacs.app/Contents/MacOS/bin/emacsclient -c +22 ~/myfile.txt
This will create a new GUI window (ie Aquamacs frame) associated with the current Aquamacs session, with myfile.txt loaded in its buffer, and the cursor at line #22. 这将创建一个与当前Aquamacs会话相关联的新GUI窗口(即Aquamacs框架),其中myfile.txt加载在其缓冲区中,光标加载到第22行。 The full path to Aquamacs's emacsclient
is obviously dependent on where you installed Aquamacs. Aquamacs的emacsclient
的完整路径显然取决于您安装Aquamacs的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.