[dired] add support for hiding dotfiles and hide details by default

This commit is contained in:
Max Nickel 2019-10-27 17:32:52 -04:00
parent 5660d7ba6b
commit 9d55e75bd8
2 changed files with 22 additions and 0 deletions

View file

@ -6,7 +6,24 @@
(interactive) (interactive)
(mapc #'kill-buffer (doom-buffers-in-mode 'dired-mode)) (mapc #'kill-buffer (doom-buffers-in-mode 'dired-mode))
(message "Killed all dired buffers")) (message "Killed all dired buffers"))
;;;###autoload ;;;###autoload
(defun +dired/enable-git-info-h () (defun +dired/enable-git-info-h ()
(if (locate-dominating-file "." ".git") (if (locate-dominating-file "." ".git")
(dired-git-info-mode 1))) (dired-git-info-mode 1)))
;;;###autoload
(defun +dired/dotfiles-hide ()
(set (make-local-variable '+dired-dotfiles-show-p) nil)
(dired-mark-files-regexp "^\\\.")
(dired-do-kill-lines))
;;;###autoload
(defun +dired/dotfiles-toggle ()
(interactive)
(when (equal major-mode 'dired-mode)
(if (or (not (boundp '+dired-dotfiles-show-p)) +dired-dotfiles-show-p) ; if currently showing
(+dired/dotfiles-hide)
(progn (revert-buffer) ; otherwise just revert to re-show
(set (make-local-variable '+dired-dotfiles-show-p) t)))))

View file

@ -45,6 +45,11 @@ only variant that supports --group-directories-first."
"--group-directories-first") "--group-directories-first")
" "))))) " ")))))
;; hide details by default
(add-hook 'dired-mode-hook 'dired-hide-details-mode)
;; hide dotfiles by default
(add-hook 'dired-after-readin-hook '+dired/dotfiles-hide)
;; Don't complain about this command being disabled when we use it ;; Don't complain about this command being disabled when we use it
(put 'dired-find-alternate-file 'disabled nil) (put 'dired-find-alternate-file 'disabled nil)