OS X: Reveal File in Console

- - posted in osx, tips

One of the neat things you can do in OS X is to reveal a file in Finder.app from some other applications. Turns out lots of the time, we also want to do that in the terminal. The following script helps you with that:

reveal
1
2
3
4
5
6
7
8
9
#!/usr/bin/osascript
on run args
  set fullpath to do shell script "realpath " & (quoted form of first item of args)
  set theFile to POSIX file fullpath
  tell application "Finder"
      reveal theFile
      activate
  end tell
end

Note:

  1. You should put this into a directory in your search path. I recommend in ~/bin. Also remember to chmod +x.
  2. The above requires another script realpath, which returns the fullpath of a file. You can find it here.

Comments