summaryrefslogtreecommitdiffstats
path: root/lisp/bandali-dired.el
diff options
context:
space:
mode:
authorAmin Bandali <bandali@gnu.org>2020-04-12 14:38:15 -0400
committerAmin Bandali <bandali@gnu.org>2020-04-12 14:38:15 -0400
commit679463c61523f4eed0ab40468e9504166863e4ac (patch)
treea354c179d17459d234b2f94a3f57f0b3dc6ae648 /lisp/bandali-dired.el
parent97141042900a4675b2fb9c8bef6bcae6c69c7f1e (diff)
downloadconfigs-679463c61523f4eed0ab40468e9504166863e4ac.tar.gz
configs-679463c61523f4eed0ab40468e9504166863e4ac.tar.xz
configs-679463c61523f4eed0ab40468e9504166863e4ac.zip
Move dired, eshell, ibuffer, ido, and ivy to separate files in lisp/
Diffstat (limited to 'lisp/bandali-dired.el')
-rw-r--r--lisp/bandali-dired.el51
1 files changed, 51 insertions, 0 deletions
diff --git a/lisp/bandali-dired.el b/lisp/bandali-dired.el
new file mode 100644
index 0000000..537ea24
--- /dev/null
+++ b/lisp/bandali-dired.el
@@ -0,0 +1,51 @@
+(use-package dired
+ :config
+ (setq dired-dwim-target t
+ dired-listing-switches "-alh"
+ ls-lisp-use-insert-directory-program nil)
+
+ ;; easily diff 2 marked files
+ ;; https://oremacs.com/2017/03/18/dired-ediff/
+ (defun dired-ediff-files ()
+ (interactive)
+ (require 'dired-aux)
+ (defvar ediff-after-quit-hook-internal)
+ (let ((files (dired-get-marked-files))
+ (wnd (current-window-configuration)))
+ (if (<= (length files) 2)
+ (let ((file1 (car files))
+ (file2 (if (cdr files)
+ (cadr files)
+ (read-file-name
+ "file: "
+ (dired-dwim-target-directory)))))
+ (if (file-newer-than-file-p file1 file2)
+ (ediff-files file2 file1)
+ (ediff-files file1 file2))
+ (add-hook 'ediff-after-quit-hook-internal
+ (lambda ()
+ (setq ediff-after-quit-hook-internal nil)
+ (set-window-configuration wnd))))
+ (error "no more than 2 files should be marked"))))
+
+ (require 'dired-x)
+ (setq dired-guess-shell-alist-user
+ '(("\\.pdf\\'" "evince" "zathura" "okular")
+ ("\\.doc\\'" "libreoffice")
+ ("\\.docx\\'" "libreoffice")
+ ("\\.ppt\\'" "libreoffice")
+ ("\\.pptx\\'" "libreoffice")
+ ("\\.xls\\'" "libreoffice")
+ ("\\.xlsx\\'" "libreoffice")
+ ("\\.flac\\'" "mpv")))
+ :bind (:map dired-mode-map
+ ("b" . dired-up-directory)
+ ("E" . dired-ediff-files)
+ ("e" . dired-toggle-read-only)
+ ("\\" . dired-hide-details-mode)
+ ("z" . (lambda ()
+ (interactive)
+ (b/dired-start-process "zathura"))))
+ :hook (dired-mode . dired-hide-details-mode))
+
+(provide 'bandali-dired)