Open the mac finder with a file/folder selected in eclipse.

It’s a common operation for eclipse users to try and open a file/folder in the mac finder. Unfortunately, there is no direct way to do it in eclipse. For windows users, this article addresses this issue. For mac users, however – a little difference is present. So how do we solve this problem?

Summary: Create an external tool with location /usr/bin/osascript and arguments -e "tell application \"Finder\"" -e "reveal POSIX file \"${resource_loc}\"" -e "activate" -e "end tell" . Any selected file or directory can now be shown in the mac finder.

Details: Create a new external tool:

(1) Create a new Program (select Program in the tree)
(2) Name it shell
(3) Set the location to /usr/bin/osascript
(4) The arguments to -e "tell application \"Finder\"" -e "reveal POSIX file \"${resource_loc}\"" -e "activate" -e "end tell"
(5) Run it:

Open the mac finder with a file or folder selected in eclipse

The argument that we passed is basically a script which tells apple finder to open the containing folder in the finder with the file selected.
If we just wanted the folder to be opened (without the file being highlighted), we could have used location as /usr/bin/open and arguments as ${container_loc}. That would tell the finder to execute “open” with the container location of the selected file.


Leave a Reply