dotfiles/emacs/.emacs.d/init/dired-init.org

1 KiB

Dired

  (require 'dired)
  (require 'dired-x)

Show human-readable sizes in dired buffers.

  (setq dired-listing-switches "-alh")

Show the same info for subdirectories, but don't show the . and .. directories, since those are most likely already shown in the buffer.

  (setq dired-subdir-switches "-Alh")

Add a keybinding to dired buffers to change to wdired.

  (defun oni:dired-add-wdired-keybinding ()
    "Add a keybinding for wdired mode."
    (define-key dired-mode-map (kbd "E") 'wdired-change-to-wdired-mode))

  (add-hook 'dired-mode-hook 'oni:dired-add-wdired-keybinding)

Open PDF files in zathura.

  (add-to-list 'dired-guess-shell-alist-user
               `(,(rx ".pdf" eos) "zathura"))

Open Jpeg, Gif and PNG files in feh.

  (add-to-list 'dired-guess-shell-alist-user
               `(,(rx (or ".jpg" ".jpeg" ".png" ".gif") eos) "feh"))