diff --git a/config/emacs/emacs.org b/config/emacs/emacs.org index 28bff1e4..6201080d 100644 --- a/config/emacs/emacs.org +++ b/config/emacs/emacs.org @@ -528,6 +528,102 @@ make sure to setup authinfo (use-package company-box :hook (company-mode . company-box-mode)) #+end_src +** Dired (quick file management in emacs) +Dired is a built-in file manager for Emacs that does some pretty amazing things! Here are some key bindings you should try out: +*** Key Bindings +**** Navigation + +*Emacs* / *Evil* +- =n= / =j= - next line +- =p= / =k= - previous line +- =j= / =J= - jump to file in buffer +- =RET= - select file or directory +- =^= - go to parent directory +- =S-RET= / =g O= - Open file in "other" window +- =M-RET= - Show file in other window without focusing (previewing files) +- =g o= (=dired-view-file=) - Open file but in a "preview" mode, close with =q= +- =g= / =g r= Refresh the buffer with =revert-buffer= after changing configuration (and after filesystem changes!) + +**** Marking files + +- =m= - Marks a file +- =u= - Unmarks a file +- =U= - Unmarks all files in buffer +- =* t= / =t= - Inverts marked files in buffer +- =% m= - Mark files in buffer using regular expression +- =*= - Lots of other auto-marking functions +- =k= / =K= - "Kill" marked items (refresh buffer with =g= / =g r= to get them back) +- Many operations can be done on a single file if there are no active marks! + +**** Copying and Renaming files + +- =C= - Copy marked files (or if no files are marked, the current file) +- Copying single and multiple files +- =U= - Unmark all files in buffer +- =R= - Rename marked files, renaming multiple is a move! +- =% R= - Rename based on regular expression: =^test= , =old-\&= + +*Power command*: =C-x C-q= (=dired-toggle-read-only=) - Makes all file names in the buffer editable directly to rename them! Press =Z Z= to confirm renaming or =Z Q= to abort. + +**** Deleting files + +- =D= - Delete marked file +- =d= - Mark file for deletion +- =x= - Execute deletion for marks +- =delete-by-moving-to-trash= - Move to trash instead of deleting permanently + +**** Creating and extracting archives + +- =Z= - Compress or uncompress a file or folder to (=.tar.gz=) +- =c= - Compress selection to a specific file +- =dired-compress-files-alist= - Bind compression commands to file extension + +**** Other common operations + +- =T= - Touch (change timestamp) +- =M= - Change file mode +- =O= - Change file owner +- =G= - Change file group +- =S= - Create a symbolic link to this file +- =L= - Load an Emacs Lisp file into Emacs +*** Configuration +#+begin_src emacs-lisp + (use-package dired + :ensure nil + :commands (dired dired-jump) + :bind (("C-x C-j" . dired-jump)) + :custom ((dired-listing-switches "-agho --group-directories-first")) + :config + (evil-collection-define-key 'normal 'dired-mode-map + "h" 'dired-single-up-directory + "l" 'dired-single-buffer)) + + (use-package dired-single) + + ;; (use-package dired-open + ;; :config + ;; (setq dired-open-extensions '(("png" . "feh") + ;; ("mkv" . "mpv")))) + + ;; (use-package dired-hide-dotfiles + ;; :hook (dired-mode . dired-hide-dotfiles-mode) + ;; :config + ;; (evil-collection-define-key 'normal 'dired-mode-map + ;; "H" 'dired-hide-dotfiles-mode)) +#+end_src +** Folder Cleaning +#+begin_src emacs-lisp +;; NOTE: If you want to move everything out of the ~/.emacs.d folder +;; reliably, set `user-emacs-directory` before loading no-littering! +;(setq user-emacs-directory "~/.cache/emacs") + +(use-package no-littering) + +;; no-littering doesn't set this by default so we must place +;; auto save files in the same path as it uses for sessions +(setq auto-save-file-name-transforms + `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))) +#+end_src * Org Mode Configuration Setup ** Babel Languages #+begin_src emacs-lisp diff --git a/config/emacs/init.el b/config/emacs/init.el index 3e0b0dbc..fd3f3b36 100644 --- a/config/emacs/init.el +++ b/config/emacs/init.el @@ -450,6 +450,40 @@ (use-package company-box :hook (company-mode . company-box-mode)) +(use-package dired + :ensure nil + :commands (dired dired-jump) + :bind (("C-x C-j" . dired-jump)) + :custom ((dired-listing-switches "-agho --group-directories-first")) + :config + (evil-collection-define-key 'normal 'dired-mode-map + "h" 'dired-single-up-directory + "l" 'dired-single-buffer)) + +(use-package dired-single) + +;; (use-package dired-open +;; :config +;; (setq dired-open-extensions '(("png" . "feh") +;; ("mkv" . "mpv")))) + +;; (use-package dired-hide-dotfiles +;; :hook (dired-mode . dired-hide-dotfiles-mode) +;; :config +;; (evil-collection-define-key 'normal 'dired-mode-map +;; "H" 'dired-hide-dotfiles-mode)) + +;; NOTE: If you want to move everything out of the ~/.emacs.d folder +;; reliably, set `user-emacs-directory` before loading no-littering! +;(setq user-emacs-directory "~/.cache/emacs") + +(use-package no-littering) + +;; no-littering doesn't set this by default so we must place +;; auto save files in the same path as it uses for sessions +(setq auto-save-file-name-transforms + `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))) + (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)