Advertisement
rmloveland

Untitled

Apr 26th, 2024 (edited)
1,450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.88 KB | None | 0 0
  1. ;; Dired "native open": Use the OS-native program for opening the file
  2. ;; type from Dired
  3.  
  4. (defvar dired-native-open-program nil "The OS-native program for opening files.")
  5.  
  6. (cond ((eq system-type 'darwin)
  7.        (setq dired-native-open-program "/usr/bin/open"))
  8.       ((eq system-type 'gnu/linux)
  9.        (setq dired-native-open-program "xdg-open"))
  10.       ((eq system-type 'windows-nt)
  11.        (setq dired-native-open-program "explorer.exe")))
  12.  
  13. (defun dired-open-with-native-open-program ()
  14.   "Open the marked files with the program associated with those file types."
  15.   (interactive)
  16.   (let ((file-list (dired-get-marked-files)))
  17.     (dired-run-shell-command
  18.      (dired-shell-stuff-it dired-native-open-program file-list t))))
  19.  
  20. (define-key dired-mode-map (kbd "M-o") #'dired-open-with-native-open-program)
  21. (define-key locate-mode-map (kbd "M-o") #'dired-open-with-native-open-program)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement