summaryrefslogtreecommitdiffstats
path: root/lisp/init-dired.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/init-dired.el')
-rw-r--r--lisp/init-dired.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/init-dired.el b/lisp/init-dired.el
index 0fbe80e..8e7f77d 100644
--- a/lisp/init-dired.el
+++ b/lisp/init-dired.el
@@ -2,13 +2,31 @@
;;; Commentary:
;;; Code:
+(defun mpolden/dired-open-or-shell-command ()
+ "Open marked files with the default external program.
+
+If PATH does not contain a suitable command for opening external
+programs, or a prefix argument is given, this function instead
+prompts for a shell command."
+ (interactive)
+ (let ((open (and (not current-prefix-arg)
+ (or (executable-find "open")
+ (executable-find "xdg-open")))))
+ (if open
+ (dired-do-shell-command open nil (dired-get-marked-files t))
+ (call-interactively 'dired-do-shell-command))))
+
(use-package dired
:init
;; show human readable sizes in dired
(setq dired-listing-switches "-alh")
+ ;; register renames in version control
+ (setq dired-vc-rename-file t)
+
:bind (:map dired-mode-map
("C-c r" . dired-toggle-read-only)
+ ("C-c o" . mpolden/dired-open-or-shell-command)
("M-<up>" . dired-up-directory)
("<backspace>" . dired-up-directory)))