Last active
October 18, 2017 22:12
-
-
Save hidsh/4602292 to your computer and use it in GitHub Desktop.
Mac: open folder by Finder from Emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun open-finder-1 (dir file) | |
(let ((script | |
(if file | |
(concat | |
"tell application \"Finder\"\n" | |
" set frontmost to true\n" | |
" make new Finder window to (POSIX file \"" dir "\")\n" | |
" select file \"" file "\"\n" | |
"end tell\n") | |
(concat | |
"tell application \"Finder\"\n" | |
" set frontmost to true\n" | |
" make new Finder window to {path to desktop folder}\n" | |
"end tell\n")))) | |
(start-process "osascript-getinfo" nil "osascript" "-e" script))) | |
(defun open-finder () | |
(interactive) | |
(let ((path (buffer-file-name)) | |
dir file) | |
(when path | |
(setq dir (file-name-directory path)) | |
(setq file (file-name-nondirectory path))) | |
(open-finder-1 dir file))) | |
(defalias 'e 'open-finder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good job