EOS: Dired Module

Table of Contents

(provide 'eos-dired)

Directory Editing and Navigation with Dired

Dired is sweet, I require dired-x also so I can hit C-x C-j and go directly to a dired buffer.

Setting ls-lisp-dirs-first means directories are always at the top. Always copy and delete recursively. Also enable hl-line-mode in dired, since it's easier to see the cursor then.

And then some other things to setup when dired runs. C-x C-q to edit writable-dired mode is aawwweeeesssoooommee, it makes renames super easy.

(defun eos/dired-mode-hook ()
  (setq-local truncate-lines t))

(use-package dired
  :bind ("C-x C-j" . dired-jump)
  :config
  (use-package dired-x
    :init (setq-default dired-omit-files-p t)
    :config
    (add-to-list 'dired-omit-extensions ".DS_Store"))
  (customize-set-variable 'diredp-hide-details-initially-flag nil)
  (use-package dired+
    :ensure t)
  (use-package dired-aux
    :init
    (use-package dired-async
      :ensure async))
  (put 'dired-find-alternate-file 'disabled nil)
  (setq ls-lisp-dirs-first t
        dired-recursive-copies 'always
        dired-recursive-deletes 'always
        dired-dwim-target t
        ;; -F marks links with @
        dired-ls-F-marks-symlinks t
        delete-by-moving-to-trash t
        ;; Don't auto refresh dired
        global-auto-revert-non-file-buffers nil
        wdired-allow-to-change-permissions t)
  (define-key dired-mode-map (kbd "C-M-u") #'dired-up-directory)
  (define-key dired-mode-map (kbd "M-o") #'my/dired-open)
  (define-key dired-mode-map (kbd "C-x C-q") #'wdired-change-to-wdired-mode)
  (bind-key "l" #'dired-up-directory dired-mode-map)
  (bind-key "M-!" #'async-shell-command dired-mode-map)
  (add-hook 'dired-mode-hook 'eos/turn-on-hl-line)
  (add-hook 'dired-mode-hook #'eos/dired-mode-hook))

Quick-preview provides a nice preview of the thing at point for files, great when using dired.

(use-package quick-preview
  :ensure t
  :init
  (global-set-key (kbd "C-c q") 'quick-preview-at-point)
  (define-key dired-mode-map (kbd "Q") 'quick-preview-at-point))

Let's also use async everything in dired

(use-package async :ensure t)
(autoload 'dired-async-mode "dired-async.el" nil t)
(dired-async-mode 1)

Dired narrowing allows filtering dired results dynamically with a filter. Very cool.

(use-package dired-narrow
  :ensure t
  :bind (:map dired-mode-map
              ("/" . dired-narrow)))

Icons in Dired buffers (and other buffers)

(use-package all-the-icons
  :ensure t)

(use-package all-the-icons-dired
  :ensure t
  :init
  (add-hook 'dired-mode-hook 'all-the-icons-dired-mode))

Collapsing multiple directories in Dired

Fuco1 has a nice blog post about this, https://fuco1.github.io/2017-07-15-Collapse-unique-nested-paths-in-dired-with-dired-collapse-mode.html

(use-package dired-collapse
  :ensure t
  :init
  (add-hook 'dired-mode-hook 'dired-collapse-mode))

Author: Lee Hinman

Created: 2017-08-21 Mon 14:28