* init.el: Delete old hack; now we have erc-switch-to-buffer-other-window
[~bandali/configs] / lisp / bandali-dired.el
... / ...
CommitLineData
1(use-package dired
2 :config
3 (setq dired-dwim-target t
4 dired-listing-switches "-alh"
5 ls-lisp-use-insert-directory-program nil)
6
7 ;; easily diff 2 marked files
8 ;; https://oremacs.com/2017/03/18/dired-ediff/
9 (defun dired-ediff-files ()
10 (interactive)
11 (require 'dired-aux)
12 (defvar ediff-after-quit-hook-internal)
13 (let ((files (dired-get-marked-files))
14 (wnd (current-window-configuration)))
15 (if (<= (length files) 2)
16 (let ((file1 (car files))
17 (file2 (if (cdr files)
18 (cadr files)
19 (read-file-name
20 "file: "
21 (dired-dwim-target-directory)))))
22 (if (file-newer-than-file-p file1 file2)
23 (ediff-files file2 file1)
24 (ediff-files file1 file2))
25 (add-hook 'ediff-after-quit-hook-internal
26 (lambda ()
27 (setq ediff-after-quit-hook-internal nil)
28 (set-window-configuration wnd))))
29 (error "no more than 2 files should be marked"))))
30
31 (require 'dired-x)
32 (setq dired-guess-shell-alist-user
33 '(("\\.pdf\\'" "evince" "zathura" "okular")
34 ("\\.doc\\'" "libreoffice")
35 ("\\.docx\\'" "libreoffice")
36 ("\\.ppt\\'" "libreoffice")
37 ("\\.pptx\\'" "libreoffice")
38 ("\\.xls\\'" "libreoffice")
39 ("\\.xlsx\\'" "libreoffice")
40 ("\\.flac\\'" "mpv")))
41 :bind (:map dired-mode-map
42 ("b" . dired-up-directory)
43 ("E" . dired-ediff-files)
44 ("e" . dired-toggle-read-only)
45 ("\\" . dired-hide-details-mode)
46 ("z" . (lambda ()
47 (interactive)
48 (b/dired-start-process "zathura"))))
49 :hook (dired-mode . dired-hide-details-mode))
50
51(provide 'bandali-dired)