a guest Feb 24th, 2018 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- ;; Make dired open certain file types externally when pressing RET on a file.
- (defvar unsupported-mime-types
- (load "subr-x")
- (defun get-mimetype (filepath)
- (shell-command-to-string (concat "file -b --mime-type " filepath))))
- (defun dired-find-file-dwim ()
- (let ((file (dired-get-filename nil t)))
- (if (member (get-mimetype file) unsupported-mime-types)
- (call-process "xdg-open" nil 0 nil file)
- (find-file file))))
- (with-eval-after-load 'dired
- (define-key dired-mode-map (kbd "RET") #'dired-find-file-dwim))
RAW Paste Data