简体   繁体   English

如何从命令行(OSX iterm)调用aquamacs来打开给定行号的文件?

[英]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”的新文件。

You may find this helpful. 您可能会觉得很有帮助。

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.

相关问题 如何在Mac OSX上从命令行在Sublime3中打开文件 - How to Open a File in Sublime3 from the Command Line on Mac OSX 我可以单击 iterm2 中的文件名和行号以在 Visual Studio Code 中以 OS X 中的正确行号打开该文件吗 - Can I click on a filename and line number in iterm2 to open that file in Visual Studio Code at the correct line number in OS X 在 OSX 上从命令行打开 AndroidStudio 项目 - Open AndroidStudio project from command line on OSX 如何从 OSX 的命令行打开 Visual Studio Code? - How to open Visual Studio Code from the command line on OSX? 在OSX上从命令行打开文件URL - Opening file urls from the command line on OSX OSX - 如何从命令行获取文件的创建和修改时间 - OSX - How to get the creation & modification time of a file from the command line 如何防止命令行java进程在OSX中窃取焦点? - How can I prevent command line java processes from stealing focus in OSX? 如何从命令行在OSX的callgrind输出中获取有意义的函数名称? - How can I get meaningful function names in callgrind output on OSX from the command line? 在osx上,如何从一个脚本打开新的iterm终端选项卡,然后在该临时窗口中运行命令 - On osx, how to open new iterm terminal tab from one script then run command in that temrinal window 如何从命令行停止 OSX 上的 mysql - How to stop mysql on OsX from the command line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM