Skip to content

Commit

Permalink
Add function to open file in operating system's default application (#38
Browse files Browse the repository at this point in the history
)
  • Loading branch information
oantolin committed Dec 6, 2020
1 parent a00aa13 commit 7d687a0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions consult.el
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,20 @@ This command obeys narrowing. Optionally INITIAL input can be provided."
(interactive)
(find-file-other-window (consult--recent-file-read)))

;;;###autoload
(defun consult-open-externally (file)
"Open FILE using system's default application."
(interactive "fOpen: ")
(if (and (eq system-type 'windows-nt)
(fboundp 'w32-shell-execute))
(w32-shell-execute "open" target)
(call-process (pcase system-type
('darwin "open")
('cygwin "cygstart")
(_ "xdg-open"))
nil 0 nil
(expand-file-name file))))

;; Use minibuffer completion as the UI for completion-at-point
(defun consult-completion-in-region (start end collection &optional predicate)
"Prompt for completion of region in the minibuffer if non-unique.
Expand Down

0 comments on commit 7d687a0

Please sign in to comment.