Files
.emacs.d/lisp/init-dired.el

137 lines
4.0 KiB
EmacsLisp
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;;; init-dired.el --- dired & dirvish -*-lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package dired
:straight nil
:config
(when *is-mac*
(setq insert-directory-program "gls"
dired-use-ls-dired t))
(setq dired-dwim-target t
dired-listing-switches
"-l --almost-all --human-readable --group-directories-first --no-group"
dired-recursive-deletes 'always
dired-recursive-copies 'always
dired-mouse-drag-files t
mouse-drag-and-drop-region-cross-program t
dired-compress-file-default-suffix ".zip"
dired-kill-when-opening-new-dired-buffer nil
dired-auto-revert-buffer t)
(put 'dired-find-alternate-file 'disabled nil))
;; dirvish
(use-package dirvish
:straight
'(dirvish :fork (:host github :repo "latiagertrutis/dirvish"))
:init
(dirvish-override-dired-mode)
:config
(require 'vc)
(if *is-windows* (require 'fix-dirvish-preview))
(if (or *is-mac* *is-android*)
(setq dirvish-hide-details t)
(setq dirvish-hide-details '(dirvish-side)))
(if *is-android*
(setq dirvish-default-layout nil
dirvish-layout-recipes '((1 0.6)))
(setq dirvish-default-layout nil
dirvish-layout-recipes '((1 0.15 0.45))))
(setq dirvish-use-mode-line t
dirvish-mode-line-format '(:left (sort omit symlink) :right (free-space index))
dirvish-attributes '(file-time file-size)
dirvish-yank-sources 'session)
:custom
(dirvish-quick-access-entries
(cond
(*is-windows*
'(("h" "~/" "Home")
("e" "~/.emacs.d/" "Emacs config")
("p" "c:/Users/gaozh/Pictures/Screenshots/" "Pictures")
("d" "f:/下载25-2-10/" "Download")
("v" "f:/luping26-1-11/" "Videos")
("n" "h:/emacs/my-org-note/" "Notes")))
(*is-mac*
'(("h" "~/" "Home")
("e" "~/.emacs.d/" "Emacs config")
("p" "~/Pictures/" "Pictures")
("d" "~/Downloads/" "Download")
("v" "~/Movies/" "Videos")
("n" "~/org/my-org-note/" "Notes")
("g" "~/gptel/" "gptel sessions")))
(*is-linux*
'(("h" "~/" "Home")
("e" "~/.emacs.d/" "Emacs config")
("s" "~/.config/guix/" "System config")
("p" "~/Pictures/" "Pictures")
("d" "~/downloads/" "Downloads")
("v" "~/视频/" "Videos")
("n" "~/org/my-org-note/" "Notes")
("g" "~/gptel/" "gptel sessions")))
(*is-android*
'(("h" "~/" "Home")
("e" "~/.emacs.d" "Emacs")
("n" "~/storage/shared/my-org-note/" "Notes")
("g" "~/gptel/" "gptel sessions")))
(t nil))))
;; gitignore
(use-package dired-gitignore
:after
(dirvish dirvish-vc transient)
:demand t
:config
(transient-define-suffix dirvish-toggle-gitignore ()
"Toggle `dired-gitignore-mode' in current Dirvish buffer."
:description
(lambda ()
(format "Gitignore filter (%s)"
(if dired-gitignore-mode
(propertize "+" 'face 'transient-value)
(propertize "-" 'face 'transient-inactive-value))))
:transient t
(interactive)
(dired-gitignore-mode 'toggle))
(transient-append-suffix 'dirvish-vc-menu "v"
'("i" dirvish-toggle-gitignore)))
;; trashed
(use-package trashed
:commands
(trashed)
:config
(setq trashed-action-confirmer 'y-or-n-p
trashed-use-header-line t
trashed-sort-key '("Date deleted" . t)
trashed-date-format "%Y-%m-%d %H:%M:%S"))
;; discomfort挂载硬盘
(when *is-linux*
(use-package debase
:straight
(debase :type git
:host codeberg
:repo "emacs-weirdware/debase"))
(use-package discomfort
:commands discomfort
:straight
(discomfort :type git
:host codeberg
:repo "emacs-weirdware/discomfort")))
(provide 'init-dired)
;;; init-dired.el ends here