Refactor core-os-osx.el

This commit is contained in:
Henrik Lissner 2015-11-13 03:51:02 -05:00
parent b69c1be4f4
commit 76ac7c4801

View file

@ -55,19 +55,25 @@
(defun narf-open-with (&optional app-name path) (defun narf-open-with (&optional app-name path)
"Send PATH to APP-NAME on OSX." "Send PATH to APP-NAME on OSX."
(interactive) (interactive)
(let* ((path (f-full (s-replace "'" "\\'" (or path (if (eq major-mode 'dired-mode) (dired-get-file-for-visit) (buffer-file-name)))))) (let* ((path (f-full (s-replace "'" "\\'"
(command (concat "open " (when app-name (concat "-a " (shell-quote-argument app-name))) " '" path "'"))) (or path (if (eq major-mode 'dired-mode)
(dired-get-file-for-visit)
(buffer-file-name))))))
(command (format "open %s"
(if app-name
(format "-a %s" (shell-quote-argument app-name))
(format "'%s'" path)))))
(message "Running: %s" command) (message "Running: %s" command)
(shell-command command))) (shell-command command)))
(defun narf-switch-to-iterm () (defun narf-switch-to-iterm ()
(interactive) (interactive)
(shell-command "osascript -e 'tell application \"iTerm2\" to activate'" nil)) (do-applescript "tell application \"iTerm2\" to activate"))
(defun narf-switch-to-iterm-and-cd () (defun narf-switch-to-iterm-and-cd ()
(interactive) (interactive)
(narf:tmux-chdir nil t) (narf:tmux-chdir nil t)
(shell-command "osascript -e 'tell application \"iTerm2\" to activate'" nil)) (narf-switch-to-iterm))
(provide 'core-os-osx) (provide 'core-os-osx)
;;; core-os-osx.el ends here ;;; core-os-osx.el ends here