简体   繁体   English

通过cmdline获取Eclipse中活动编辑器的文件路径

[英]Get filepath of active editor in Eclipse via cmdline

I want to know the filepath of the currently active editor in Eclipse from outside of eclipse. 我想从eclipse之外了解Eclipse中当前活动的编辑器的文件路径。 Using AppleScript doesn't work, but maybe there are other ways, like JMX, MBeans or something like that...?! 使用AppleScript不起作用,但是也许还有其他方法,例如JMX,MBean或类似方法……?!

In AppleScript I would do something like... 在AppleScript中,我会做类似...

$ osascript -e 'tell app "TextEdit" to return path of first document'
/Users/muhqu/Desktop/HelloWorld.txt

I found a way by using Eclipse's window title. 我通过使用Eclipse的窗口标题找到了一种方法。 The window title includes the path to the current workspace and also the package-relative path of the current active file. 窗口标题包括当前工作空间的路径,以及当前活动文件的程序包相对路径。

FILEPATH="$(find "$WORKSPACE" -path '*'"${PACKAGE_RELATIVE_FILEPATH#*/}")"

For the complete script see this Gist . 有关完整的脚本,请参见此要点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM