简体   繁体   中英

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. Using AppleScript doesn't work, but maybe there are other ways, like JMX, MBeans or something like that...?!

In AppleScript I would do something like...

$ 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. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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