### Install Dirvish and Prepare Emacs Configuration Source: https://github.com/alexluigit/dirvish/blob/main/docs/EMACS-NEWCOMERS.org Clone the Dirvish repository, copy the example Emacs configuration, and start the Emacs daemon. This setup is for users new to Emacs and Dirvish. ```bash # Clone the repo git clone https://github.com/alexluigit/dirvish ~/dirvish # Prepare the Emacs config cp ~/dirvish/docs/.emacs.d.example ~/.emacs.d # Start Emacs daemon (wait for the package installation) emacs --daemon # Open Emacs emacsclient -cn ``` -------------------------------- ### Install coreutils via Scoop Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Installs the coreutils package on Windows using Scoop. This is a prerequisite for certain functionalities. ```shell scoop install coreutils ``` -------------------------------- ### Install fd via Scoop Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Command to install the fd utility on Windows using the Scoop package manager. ```shell scoop install fd ``` -------------------------------- ### Install Dirvish Dependencies on Arch-based Systems Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Use pacman to install the necessary tools for file previewing and metadata generation on Arch-based Linux distributions. ```bash pacman -S poppler ffmpegthumbnailer mediainfo libvips 7zip imagemagick ``` -------------------------------- ### Install fd on macOS Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Installs the 'fd' command-line utility on macOS using Homebrew. Ensure Homebrew is installed before running this command. ```bash brew install fd ``` -------------------------------- ### Install fd on FreeBSD Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Installs the 'fd-find' package on FreeBSD using pkg. This command requires root privileges. ```bash pkg install fd-find ``` -------------------------------- ### Configure UI with Setup Menu Source: https://context7.com/alexluigit/dirvish/llms.txt Interactively configure Dirvish attributes and layouts using the `dirvish-setup-menu`. This menu allows toggling attributes, switching layouts, and applying settings. ```elisp ;; Open setup menu (dirvish-setup-menu) ``` ```elisp ;; Toggle attributes, switch layouts, apply settings (define-key dirvish-mode-map (kbd "a") 'dirvish-setup-menu) ``` -------------------------------- ### Install Dirvish Dependencies on FreeBSD Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Use pkg to install the required packages for file previewing and metadata generation on FreeBSD. ```bash pkg install poppler ffmpegthumbnailer vips 7-zip ImageMagick7 ``` -------------------------------- ### Install Dirvish Dependencies via Scoop Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Installs necessary tools for Dirvish preview methods using Scoop package manager. ```shell scoop install poppler mtn mediainfo libvips 7zip imagemagick ``` -------------------------------- ### Install Dirvish Dependencies on Debian-based Systems Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Use apt to install the required packages for file previewing and metadata generation on Debian-based Linux distributions. ```bash apt install poppler-utils ffmpegthumbnailer mediainfo libvips-tools imagemagick ``` -------------------------------- ### Install GNU coreutils on macOS Source: https://github.com/alexluigit/dirvish/blob/main/docs/FAQ.org Install GNU ls to resolve directory listing errors on macOS. ```bash brew install coreutils ``` -------------------------------- ### Install Dirvish Dependencies on macOS Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Use Homebrew to install the necessary tools for file previewing and metadata generation on macOS. ```bash brew install poppler ffmpegthumbnailer mediainfo vips 7zip imagemagick ``` -------------------------------- ### Define and register azw3 preview dispatcher Source: https://github.com/alexluigit/dirvish/wiki/Contrib-preview-dispatchers Registers a custom preview handler for azw3 and mobi files. Requires the ebook-meta executable to be installed on the system. ```elisp (dirvish-define-preview azw3 (file ext preview-window) "Preview azw3 files. Require: `ebook-meta' (executable)" :require ("ebook-meta") (when (member ext '("azw3" "mobi")) (let* ((width (dirvish-media--img-size preview-window)) (height (dirvish-media--img-size preview-window 'height)) (cache (dirvish--img-thumb-name file width ".jpg"))) (if (file-exists-p cache) `(img . ,(create-image cache nil nil :max-width width :max-height height)) `(cache . ("ebook-meta" "--get-cover" ,cache ,file)))))) (push 'azw3 dirvish-preview-dispatchers) ``` -------------------------------- ### Install fd on Debian-based systems Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Installs the 'fd-find' package on Debian-based Linux distributions using apt. This command requires root privileges. ```bash apt install fd-find ``` -------------------------------- ### Define Custom Preview Dispatcher in Elisp Source: https://context7.com/alexluigit/dirvish/llms.txt Create custom preview dispatchers for specific file types using 'dirvish-define-preview'. This example shows how to use 'eza' for directory previews and 'glow' for markdown files. Ensure the required executables are in your system's PATH. ```elisp ;; Preview directories using eza command (dirvish-define-preview eza (file) "Use `eza' to generate directory preview." :require ("eza") ; check for executable (when (file-directory-p file) `(shell . ("eza" "-al" "--color=always" "--icons=always" "--group-directories-first" ,file)))) ;; Add to beginning of dispatchers (takes precedence) (push 'eza dirvish-preview-dispatchers) ;; Preview markdown files rendered (dirvish-define-preview markdown (file ext) "Preview markdown files." (when (member ext '("md" "markdown")) `(shell . ("glow" "-s" "dark" ,file)))) ``` -------------------------------- ### Configure Dirvish Preview Dispatchers Source: https://context7.com/alexluigit/dirvish/llms.txt Manage which preview methods are active for different file types by setting 'dirvish-preview-dispatchers'. This list specifies the order in which previewers are attempted. Ensure required external tools are installed for each dispatcher. ```elisp ;; Default preview dispatchers (setq dirvish-preview-dispatchers '(image gif video audio epub pdf archive)) ;; Dispatcher requirements: ;; - image: vipsthumbnail ;; - gif: built-in (animated preview) ;; - video: ffmpegthumbnailer (Linux/macOS) or mtn (Windows) ;; - audio: mediainfo ;; - epub: epub-thumbnailer ;; - pdf: pdftoppm (or pdf-tools package) ;; - archive: 7z ;; Remove a dispatcher (e.g., disable epub preview) (setq dirvish-preview-dispatchers (remove 'epub dirvish-preview-dispatchers)) ;; Use pdf-tools instead of pdftoppm (setq dirvish-preview-dispatchers (cl-substitute 'pdf-tools 'pdf dirvish-preview-dispatchers)) ``` -------------------------------- ### Install fd on Arch-based systems Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Installs the 'fd' package on Arch-based Linux distributions using pacman. This command requires root privileges. ```bash pacman -S fd ``` -------------------------------- ### Install GNU ls on non-Linux systems Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Commands to install GNU ls on macOS and FreeBSD to satisfy the insert-directory-program requirement. ```bash # macOS brew install coreutils # FreeBSD pkg install gnuls ``` -------------------------------- ### Configure VSCode Icons for Dirvish Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Alternatively, configure `vscode-icon` as the icon backend for Dirvish. This example shows how to add JPG files to the `vscode-icon-file-alist`. ```emacs-lisp ;; (use-package vscode-icon ;; :config ;; (push '("jpg" . "image") vscode-icon-file-alist)) ``` -------------------------------- ### Configure Nerd Icons for Dirvish Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Set up `nerd-icons` as the icon backend for Dirvish. This snippet assumes `nerd-icons` is installed and ready to be used. ```emacs-lisp (use-package nerd-icons) ``` -------------------------------- ### Define File Grouping Criteria with Emacs Lisp Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Configure the 'dirvish-emerge-groups' variable to define criteria for grouping files. This example shows how to group by recent files, document types, video, pictures, audio, and archives. It's recommended to manage this variable via the 'dirvish-emerge-menu' transient menu. ```emacs-lisp ;; Header string | Type | Criterias '(("Recent files" (predicate . recent-files-2h)) ("Documents" (extensions "pdf" "tex" "bib" "epub")) ("Video" (extensions "mp4" "mkv" "webm")) ("Pictures" (extensions "jpg" "png" "svg" "gif")) ("Audio" (extensions "mp3" "flac" "wav" "ape" "aac")) ("Archives" (extensions "gz" "rar" "zip"))) ``` -------------------------------- ### Configure TRAMP for Dirvish Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Configure TRAMP for enhanced Dirvish integration over SSH connections. This setup optimizes performance for asynchronous remote processes and speeds up connections. ```emacs-lisp (use-package tramp :config ;; Enable full-featured Dirvish over TRAMP on ssh connections ;; https://www.gnu.org/software/tramp/#Improving-performance-of-asynchronous-remote-processes (connection-local-set-profile-variables 'remote-direct-async-process '((tramp-direct-async-process . t))) (connection-local-set-profiles '(:application tramp :protocol "ssh") 'remote-direct-async-process) ;; Tips to speed up connections (setq tramp-verbose 0) (setq tramp-chunksize 2000) (setq tramp-ssh-controlmaster-options nil)) ``` -------------------------------- ### Configure Default Window Layout Source: https://context7.com/alexluigit/dirvish/llms.txt Set the default ratios for parent directory and preview windows. ```elisp ;; Format: (DEPTH MAX-PARENT-WIDTH PREVIEW-WIDTH) ;; DEPTH: number of parent directory windows (0 to hide parents) ;; MAX-PARENT-WIDTH: max width ratio for each parent window ;; PREVIEW-WIDTH: width ratio for preview window ;; Default layout: 1 parent, 11% parent width, 55% preview width (setq dirvish-default-layout '(1 0.11 0.55)) ;; No parent windows, 40% preview (setq dirvish-default-layout '(0 0 0.4)) ;; Large preview (80%), small parent (8%) (setq dirvish-default-layout '(1 0.08 0.8)) ;; Disable layout on startup (no preview by default) (setq dirvish-default-layout nil) ``` -------------------------------- ### Cycle Through Layout Recipes Source: https://context7.com/alexluigit/dirvish/llms.txt Define and switch between multiple layout configurations. ```elisp ;; Define multiple layout recipes (setq dirvish-layout-recipes '((0 0 0.4) ; current + small preview (0 0 0.8) ; current + large preview (1 0.08 0.8) ; parent + current + large preview (1 0.11 0.55))) ; parent + current + medium preview ;; Cycle to next layout (dirvish-layout-switch) ;; Switch to specific layout (dirvish-layout-switch '(0 0 0.8)) ``` -------------------------------- ### Core Entry Points Source: https://context7.com/alexluigit/dirvish/llms.txt Functions to initialize and manage Dirvish sessions within Emacs. ```APIDOC ## (dirvish [path]) ### Description Opens a full-frame Dirvish session. If a path is provided, it opens that directory; otherwise, it defaults to the current directory. ### Method Function Call ### Parameters - **path** (string) - Optional - The directory path to open. ## (dirvish-dwim [path]) ### Description Smart window management: opens Dirvish in full-frame mode if the current window is the only one, otherwise opens it within the selected window. ### Method Function Call ### Parameters - **path** (string) - Optional - The directory path to open. ## (dirvish-override-dired-mode [arg]) ### Description Global minor mode that replaces standard Dired functionality with Dirvish. ### Method Function Call ### Parameters - **arg** (integer) - Optional - Use -1 to disable the mode. ``` -------------------------------- ### Define Quick Access Bookmarks Source: https://context7.com/alexluigit/dirvish/llms.txt Define custom keybindings for quick navigation to frequently used directories or remote locations. Access these bookmarks using the `dirvish-quick-access` command. ```elisp ;; Define quick access entries (KEY PATH DESCRIPTION) (setq dirvish-quick-access-entries '(("h" "~/") ("d" "~/Downloads/") ("p" "~/Projects/") ("c" "~/.config/") ("s" "/ssh:server:/home/user") ("e" "/sudo:root@localhost:/etc/") ("t" "~/.local/share/Trash/files/"))) ;; Access via dirvish-quick-access command (define-key dirvish-mode-map (kbd "o") 'dirvish-quick-access) ``` -------------------------------- ### Enable Dirvish Emerge Mode on Directory Entry Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Add `dirvish-emerge-mode` to `dirvish-setup-hook` to ensure groups defined in `~dirvish-emerge-groups~` are emerged when entering a directory. ```emacs-lisp (add-hook 'dirvish-setup-hook 'dirvish-emerge-mode) ``` -------------------------------- ### Configure Dirvish with use-package Source: https://context7.com/alexluigit/dirvish/llms.txt A complete configuration block for Dirvish, including Dired overrides, quick access entries, display attributes, and custom keybindings. ```elisp (use-package dired :config (setq dired-listing-switches "-l --almost-all --human-readable --group-directories-first --no-group") (put 'dired-find-alternate-file 'disabled nil)) (use-package dirvish :ensure t :init (dirvish-override-dired-mode) :custom (dirvish-quick-access-entries '(("h" "~/" "Home") ("d" "~/Downloads/" "Downloads") ("p" "~/Projects/" "Projects") ("c" "~/.config/" "Config"))) :config ;; Enable minibuffer file preview ;; (dirvish-peek-mode) ;; Enable sidebar follow mode ;; (dirvish-side-follow-mode) ;; Configure display (setq dirvish-mode-line-format '(:left (sort symlink) :right (omit yank index))) (setq dirvish-attributes '(vc-state subtree-state nerd-icons collapse git-msg file-time file-size)) (setq dirvish-side-attributes '(vc-state nerd-icons collapse file-size)) ;; Use fd for large directories (setq dirvish-large-directory-threshold 20000) :bind (("C-c f" . dirvish) ("C-c s" . dirvish-side) :map dirvish-mode-map (";" . dired-up-directory) ("?" . dirvish-dispatch) ("a" . dirvish-setup-menu) ("f" . dirvish-file-info-menu) ("o" . dirvish-quick-access) ("s" . dirvish-quicksort) ("r" . dirvish-history-jump) ("l" . dirvish-ls-switches-menu) ("v" . dirvish-vc-menu) ("y" . dirvish-yank-menu) ("N" . dirvish-narrow) ("TAB" . dirvish-subtree-toggle) ("M-f" . dirvish-history-go-forward) ("M-b" . dirvish-history-go-backward))) ;; Additional packages for enhanced experience (use-package nerd-icons) (use-package diredfl :hook ((dired-mode . diredfl-mode) (dirvish-directory-view-mode . diredfl-mode))) ``` -------------------------------- ### Open Main Command Menu Source: https://context7.com/alexluigit/dirvish/llms.txt Access all Dirvish commands through a transient menu using `dirvish-dispatch`. This menu can be bound to a key, such as `?`, for quick access to help and commands. ```elisp ;; Open main menu (dirvish-dispatch) ``` ```elisp ;; Bind to ? for quick help (define-key dirvish-mode-map (kbd "?") 'dirvish-dispatch) ``` -------------------------------- ### Use pdf-tools for PDF Previews Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Replaces the default PDF preview dispatcher with 'pdf-tools' for a fully functional PDF buffer in the preview window. ```emacs-lisp (setq dirvish-preview-dispatchers (cl-substitute 'pdf-tools 'pdf dirvish-preview-dispatchers)) ``` -------------------------------- ### Configure dired-omit-mode to Hide Dotfiles Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Configure `dired-omit-mode` to hide all dotfiles by default. This setting modifies the `dired-omit-files` variable to include a pattern for files starting with a dot. ```emacs-lisp (use-package dired-x :config ;; Make dired-omit-mode hide all "dotfiles" (setq dired-omit-files (concat dired-omit-files "\|^\..*$"))) ``` -------------------------------- ### Configure insert-directory-program Source: https://github.com/alexluigit/dirvish/blob/main/docs/FAQ.org Set the directory listing program to gls. ```emacs-lisp (setq insert-directory-program "gls") ``` -------------------------------- ### Live Narrowing of Dirvish Buffer Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Provides live filtering of files within Dirvish buffers using `dirvish-narrow`. It supports `orderless` for advanced completion or `split-string` as a fallback. Two-stage filtering with `fd` is enabled when input starts with '#'. ```emacs-lisp dirvish-narrow ``` ```emacs-lisp completion-regexp-list ``` ```emacs-lisp split-string ``` ```emacs-lisp dirvish-fd ``` -------------------------------- ### Configure Visual Indicators Source: https://context7.com/alexluigit/dirvish/llms.txt Set file attributes to display in the listing, such as icons, git status, and file metadata. ```elisp ;; Available attributes: ;; - subtree-state: directory expansion indicator ;; - nerd-icons / all-the-icons / vscode-icon: file icons ;; - collapse: collapsed unique nested paths ;; - git-msg: git commit message ;; - vc-state: version control state at left fringe ;; - file-size: file size or directory file count ;; - file-time: modification time ;; - file-modes: permission string (-rw-r--r--) ;; Recommended configuration (setq dirvish-attributes '(vc-state subtree-state nerd-icons collapse git-msg file-time file-size)) ;; Minimal configuration (just icons and size) (setq dirvish-attributes '(nerd-icons file-size)) ;; After changing, revert buffer with 'g' to apply ``` -------------------------------- ### Configure Dirvish in Emacs Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Sample configuration for Dirvish using use-package, including custom keybindings, attribute settings, and large directory threshold configuration. ```emacs-lisp (use-package dired :config (setq dired-listing-switches "-l --almost-all --human-readable --group-directories-first --no-group") ;; this command is useful when you want to close the window of `dirvish-side' ;; automatically when opening a file (put 'dired-find-alternate-file 'disabled nil)) (use-package dirvish :ensure t :init (dirvish-override-dired-mode) :custom (dirvish-quick-access-entries ; It's a custom option, `setq' won't work '(("h" "~/" "Home") ("d" "~/Downloads/" "Downloads") ("m" "/mnt/" "Drives") ("s" "/ssh:my-remote-server") "SSH server" ("e" "/sudo:root@localhost:/etc") "Modify program settings" ("t" "~/.local/share/Trash/files/" "TrashCan"))) :config ;; (dirvish-peek-mode) ; Preview files in minibuffer ;; (dirvish-side-follow-mode) ; similar to `treemacs-follow-mode' (setq dirvish-mode-line-format '(:left (sort symlink) :right (omit yank index))) (setq dirvish-attributes ; The order *MATTERS* for some attributes '(vc-state subtree-state nerd-icons collapse git-msg file-time file-size) dirvish-side-attributes '(vc-state nerd-icons collapse file-size)) ;; open large directory (over 20000 files) asynchronously with `fd' command (setq dirvish-large-directory-threshold 20000) :bind ; Bind `dirvish-fd|dirvish-side|dirvish-dwim' as you see fit (("C-c f" . dirvish) :map dirvish-mode-map ; Dirvish inherits `dired-mode-map' (";" . dired-up-directory) ; So you can adjust `dired' bindings here ("?" . dirvish-dispatch) ; [?] a helpful cheatsheet ("a" . dirvish-setup-menu) ; [a]ttributes settings:`t' toggles mtime, `f' toggles fullframe, etc. ("f" . dirvish-file-info-menu) ; [f]ile info ("o" . dirvish-quick-access) ; [o]pen `dirvish-quick-access-entries' ("s" . dirvish-quicksort) ; [s]ort flie list ("r" . dirvish-history-jump) ; [r]ecent visited ("l" . dirvish-ls-switches-menu) ; [l]s command flags ("v" . dirvish-vc-menu) ; [v]ersion control commands ("*" . dirvish-mark-menu) ("y" . dirvish-yank-menu) ("N" . dirvish-narrow) ("^" . dirvish-history-last) ("TAB" . dirvish-subtree-toggle) ("M-f" . dirvish-history-go-forward) ("M-b" . dirvish-history-go-backward) ("M-e" . dirvish-emerge-menu))) ``` -------------------------------- ### Configure Dirvish Side Window Parameters Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Set window parameters for the Dirvish side window via `dirvish-side-window-parameters`. ```emacs-lisp dirvish-side-window-parameters ``` -------------------------------- ### Configure Dirvish Side Window File Open Action Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Define the action to perform before opening a file in the Dirvish side window using `dirvish-side-open-file-action`. ```emacs-lisp dirvish-side-open-file-action ``` -------------------------------- ### Open Dirvish File Manager Source: https://context7.com/alexluigit/dirvish/llms.txt Functions to launch a Dirvish session in the current or a specified directory. ```elisp ;; Open Dirvish in current directory (dirvish) ;; Open Dirvish in a specific directory (dirvish "/path/to/directory") ;; With C-u prefix, prompt for directory ;; M-x dirvish with C-u will interactively ask for path ``` -------------------------------- ### Enable Custom 'eza' Previewer Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Adds the custom 'eza' previewer to the `dirvish-preview-dispatchers` list, making it the active preview method for directories. ```emacs-lisp (push 'eza dirvish-preview-dispatchers) ``` -------------------------------- ### Configure Dirvish Preview Dispatchers for VC Integration Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Ensure VC preview dispatchers like `vc-log`, `vc-diff`, or `vc-blame` are placed at the beginning of `dirvish-preview-dispatchers` to enable them by default. These are mutually exclusive. ```emacs-lisp ;; `vc-diff' will be ignored (vc-log vc-diff ...) ``` -------------------------------- ### dirvish-define-preview Source: https://context7.com/alexluigit/dirvish/llms.txt Create custom preview dispatchers for specific file types. ```APIDOC ## dirvish-define-preview ### Description Create custom preview dispatchers for specific file types. ### Request Example (dirvish-define-preview eza (file) "Use `eza` to generate directory preview." :require ("eza") (when (file-directory-p file) `(shell . ("eza" "-al" "--color=always" "--icons=always" "--group-directories-first" ,file)))) ``` -------------------------------- ### Layout and Display Configuration Source: https://context7.com/alexluigit/dirvish/llms.txt Functions and variables for controlling window layouts and preview panes. ```APIDOC ## dirvish-default-layout ### Description Variable to configure the default window layout recipe. ### Format (DEPTH MAX-PARENT-WIDTH PREVIEW-WIDTH) - **DEPTH**: Number of parent directory windows. - **MAX-PARENT-WIDTH**: Width ratio for parent windows. - **PREVIEW-WIDTH**: Width ratio for the preview window. ## (dirvish-layout-toggle) ### Description Interactively toggles between full-frame layout and single-window mode. ## (dirvish-layout-switch [recipe]) ### Description Cycles through or sets a specific layout recipe defined in `dirvish-layout-recipes`. ``` -------------------------------- ### Manage Dirvish Windows with DWIM Source: https://context7.com/alexluigit/dirvish/llms.txt Smart window management that opens Dirvish full-frame only if the current window is the sole window. ```elisp ;; Smart open - full-frame if only window, otherwise single window (dirvish-dwim) ;; Open in specific directory with smart behavior (dirvish-dwim "~/Documents") ;; Bind to a convenient key (global-set-key (kbd "C-c f") 'dirvish-dwim) ``` -------------------------------- ### Configure Dirvish Side Window Display Actions Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Specify display actions for the Dirvish side window using `dirvish-side-display-alist`. ```emacs-lisp dirvish-side-display-alist ``` -------------------------------- ### Define Custom 'eza' Previewer for Directories Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Defines a custom previewer named 'eza' that uses the 'eza' command to generate directory listings with icons and color. ```emacs-lisp (dirvish-define-preview eza (file) "Use `eza' to generate directory preview." :require ("eza") ; tell Dirvish to check if we have the executable (when (file-directory-p file) ; we only interest in directories here `(shell . ("eza" "-al" "--color=always" "--icons=always" "--group-directories-first" ,file)))) ``` -------------------------------- ### Configure Dirvish Sidebar Follow Mode Source: https://context7.com/alexluigit/dirvish/llms.txt Enable or disable 'dirvish-side-follow-mode' to automatically track the current buffer's file in the sidebar. You can also configure auto-expansion of parent directories and the action performed before opening a file from the sidebar. ```elisp ;; Enable follow mode (dirvish-side-follow-mode 1) ;; Auto-expand parent directories to show current file (setq dirvish-side-auto-expand t) ;; Action before opening file from sidebar (setq dirvish-side-open-file-action nil) ; use most-recent window ``` -------------------------------- ### Disable preview and parent windows Source: https://github.com/alexluigit/dirvish/blob/main/docs/FAQ.org Set the default layout to nil to disable preview and parent windows on startup. ```emacs-lisp ;; consult its docstring for more info (setq dirvish-default-layout nil) ``` -------------------------------- ### Enable Global Dired Enhancement Source: https://context7.com/alexluigit/dirvish/llms.txt Global minor mode to replace standard Dired functionality with Dirvish. ```elisp ;; Enable Dirvish globally (recommended in init.el) (dirvish-override-dired-mode) ;; After enabling, all dired commands use Dirvish ;; M-x dired, C-x d, and find-file on directories all open Dirvish ;; To disable (dirvish-override-dired-mode -1) ``` -------------------------------- ### Configure Dirvish Peek Mode Preview Behavior Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Adjust `dirvish-peek-key` to control minibuffer file preview behavior in `dirvish-peek-mode`. Options range from immediate automatic previews to manual triggering or disabling previews entirely. ```emacs-lisp 'any ``` ```emacs-lisp (list :debounce 0.5 'any) ``` ```emacs-lisp "M-." ``` ```emacs-lisp (list :debounce 0.5 "M-.") ``` ```emacs-lisp nil ``` -------------------------------- ### Live Filter Files with dirvish-narrow Source: https://context7.com/alexluigit/dirvish/llms.txt Filter the file listing in real-time as you type. Press `RET` to finalize the filter, `C-g` to cancel, or `g` to revert to the full view. Supports advanced matching and two-stage filtering in `fd` buffers. ```elisp ;; Start live narrowing (dirvish-narrow) ``` -------------------------------- ### dirvish-side Source: https://context7.com/alexluigit/dirvish/llms.txt Toggle a sidebar file browser similar to treemacs. ```APIDOC ## dirvish-side ### Description Toggle a sidebar file browser similar to treemacs. ### Request Example (dirvish-side "~/Projects") ``` -------------------------------- ### Configure Dirvish Mouse Keybindings Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Set up custom keybindings for mouse clicks in Dirvish mode. This allows for actions like toggling directory expansion or opening files with different mouse buttons. ```emacs-lisp (setq mouse-1-click-follows-link nil) (define-key dirvish-mode-map (kbd "") 'dirvish-subtree-toggle-or-open) (define-key dirvish-mode-map (kbd "") 'dired-mouse-find-file-other-window) (define-key dirvish-mode-map (kbd "") 'dired-mouse-find-file) ``` -------------------------------- ### Specify Disabled Preview Extensions Source: https://context7.com/alexluigit/dirvish/llms.txt Configure a list of file extensions that should not be previewed by Dirvish using 'dirvish-preview-disabled-exts'. This is useful for disabling previews for binary or sensitive file types. ```elisp ;; Default disabled extensions (setq dirvish-preview-disabled-exts '("bin" "exe" "gpg" "elc" "eln")) ;; Add more extensions (setq dirvish-preview-disabled-exts '("bin" "exe" "gpg" "elc" "eln" "iso" "dmg" "dll" "so")) ``` -------------------------------- ### Configure Directory View Mode Hook Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Adds `diredfl-mode` to the `dirvish-directory-view-mode-hook` to configure both parent directory listings and dired preview buffers. ```emacs-lisp (add-hook 'dirvish-directory-view-mode-hook #'diredfl-mode) ``` -------------------------------- ### Quick Access to Frequently Visited Places in Dirvish Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Enables jumping to filesystem locations with minimal keystrokes by defining entries in `dirvish-quick-access-entries` and calling `dirvish-quick-access`. ```emacs-lisp dirvish-quick-access-entries ``` ```emacs-lisp dirvish-quick-access ``` -------------------------------- ### Toggle Full-Frame Layout Source: https://context7.com/alexluigit/dirvish/llms.txt Interactively toggle between full-frame and single-window modes. ```elisp ;; Toggle layout interactively (dirvish-layout-toggle) ;; Bind to key in dirvish-mode-map (define-key dirvish-mode-map (kbd "f") 'dirvish-layout-toggle) ``` -------------------------------- ### Multi-Stage Copy and Move Operations Source: https://context7.com/alexluigit/dirvish/llms.txt Perform two-stage copy, move, symlink, and hardlink operations across multiple buffers. Mark files in the source buffer, navigate to the destination, and then execute the desired operation. ```elisp ;; Use the yank menu for all operations (define-key dirvish-mode-map (kbd "y") 'dirvish-yank-menu) ``` -------------------------------- ### Default Dirvish Preview Dispatchers Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Lists the default preview dispatchers enabled in Dirvish. These handle previews for images, GIFs, videos, audio, EPUBs, PDFs, and archives. ```emacs-lisp (image gif video audio epub pdf archive) ``` -------------------------------- ### Configure Dirvish Side Window Header Line Format Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Define the header line format for the Dirvish side window with `dirvish-side-header-line-format`, similar to `dirvish-header-line-format`. ```emacs-lisp dirvish-side-header-line-format ``` -------------------------------- ### Rsync File Transfer Configuration Source: https://context7.com/alexluigit/dirvish/llms.txt Transfer files using `rsync` for efficient handling of large files. Configure default `rsync` arguments or use the `dirvish-rsync-switches-menu` for one-time adjustments. ```elisp ;; After marking files and navigating to destination (dirvish-rsync) ``` ```elisp ;; Configure rsync arguments (setq dirvish-rsync-args '("-avz" "--progress")) ``` ```elisp ;; Use rsync switches menu for one-time adjustments (dirvish-rsync-switches-menu) ``` -------------------------------- ### Configure Dirvish Side Window Mode Line Format Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Set the mode line format for the Dirvish side window using `dirvish-side-mode-line-format`, analogous to `dirvish-mode-line-format`. ```emacs-lisp dirvish-side-mode-line-format ``` -------------------------------- ### Configure Dirvish Header Line Format Source: https://context7.com/alexluigit/dirvish/llms.txt Customize the header line at the top of directory panes. This can include the current directory path and free disk space. The header line can also be hidden or made to span all panes. ```elisp ;; Show path on left, free space on right (setq dirvish-header-line-format '(:left (path) :right (free-space))) ;; Hide header line (shows classic Dired header) (setq dirvish-use-header-line nil) ;; Make header span all panes (setq dirvish-use-header-line 'global) ;; Customize heights (single-window . full-frame) (setq dirvish-header-line-height '(25 . 35)) (setq dirvish-mode-line-height 25) ``` -------------------------------- ### Customize Dirvish layout Source: https://github.com/alexluigit/dirvish/blob/main/docs/FAQ.org Adjust the default layout for Dirvish windows. ```emacs-lisp (setq dirvish-default-layout '(0 0.4 0.6)) ``` -------------------------------- ### Configure Dirvish to open binary files externally Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org This Emacs Lisp code defines a function to detect binary files by extension and open them externally when not in dired mode. It hooks into `dirvish-find-entry-hook` to intercept file opening. ```emacs-lisp (defun dirvish-open-binaries-externally (file fn) "When FN is not `dired', open binary FILE externally." (when-let* (((not (eq fn 'dired))) ((file-exists-p file))) ((not (file-directory-p file))) ((member (downcase (or (file-name-extension file) "")) dirvish-binary-exts))) ;; return t to terminate `dirvish--find-entry'. (prog1 t (dired-do-open)))) (add-hook 'dirvish-find-entry-hook #'dirvish-open-binaries-externally) ``` -------------------------------- ### Configure Dirvish Side Window Attributes Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Customize attributes for the Dirvish side window using `dirvish-side-attributes`, similar to `dirvish-attributes` for the main window. ```emacs-lisp dirvish-side-attributes ``` -------------------------------- ### File Attributes Configuration Source: https://context7.com/alexluigit/dirvish/llms.txt Configuration for visual indicators displayed in the file listing. ```APIDOC ## dirvish-attributes ### Description A list variable defining which visual indicators to display for each file. ### Supported Attributes - **subtree-state**: Directory expansion indicator - **nerd-icons / all-the-icons / vscode-icon**: File icons - **collapse**: Collapsed unique nested paths - **git-msg**: Git commit message - **vc-state**: Version control state - **file-size**: File size or directory count - **file-time**: Modification time - **file-modes**: Permission string ``` -------------------------------- ### Dirvish History Navigation Commands Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Provides commands for navigating recently visited directories and session history. Use `dirvish-history-sort-function` to customize sorting for `dirvish-history-jump`. ```emacs-lisp dirvish-history-jump ``` ```emacs-lisp dirvish-history-go-forward ``` ```emacs-lisp dirvish-history-go-backward ``` ```emacs-lisp dirvish-history-last ``` ```emacs-lisp dirvish-history-sort-function ``` -------------------------------- ### Configure Dirvish Mode Line Format Source: https://context7.com/alexluigit/dirvish/llms.txt Set the format for the mode line (bottom status line) in Dirvish directory panes. Available segments include sort criteria, symlink targets, file paths, and version control information. ```elisp ;; Available segments: ;; - sort: current sort criteria ;; - omit: dired-omit-mode indicator ;; - symlink: symlink target path ;; - index: line number / total count ;; - free-space: free space on filesystem ;; - path: current directory path ;; - file-size, file-modes, file-time, file-user, file-group ;; - vc-info: version control info (from dirvish-vc) ;; - yank: file transfer progress (from dirvish-yank) ;; Configure left and right aligned segments (setq dirvish-mode-line-format '(:left (sort symlink) :right (omit yank index))) ;; More detailed mode line (setq dirvish-mode-line-format '(:left (sort file-time " " file-size symlink) :right (omit yank index))) ;; Hide mode line completely (setq dirvish-use-mode-line nil) ;; Make mode line span all panes (including preview) (setq dirvish-use-mode-line 'global) ``` -------------------------------- ### dirvish-header-line-format Source: https://context7.com/alexluigit/dirvish/llms.txt Configure the header line displayed at the top of directory panes. ```APIDOC ## dirvish-header-line-format ### Description Configure the header line displayed at the top of directory panes. ### Request Example (setq dirvish-header-line-format '(:left (path) :right (free-space))) ``` -------------------------------- ### Toggle and Configure Dirvish Sidebar Source: https://context7.com/alexluigit/dirvish/llms.txt Control the Dirvish sidebar, which functions similarly to treemacs. You can toggle it, open it in a specific directory, bind it to a key, and customize its width, display alignment, and attributes. ```elisp ;; Toggle sidebar in project root (dirvish-side) ;; Open sidebar in specific directory (dirvish-side "~/Projects") ;; Bind to key (global-set-key (kbd "C-c s") 'dirvish-side) ;; Configure sidebar appearance (setq dirvish-side-width 40) (setq dirvish-side-display-alist '((side . left) (slot . -1))) ;; Use different attributes for sidebar (setq dirvish-side-attributes '(vc-state nerd-icons collapse file-size)) ``` -------------------------------- ### Search Files with fd Source: https://context7.com/alexluigit/dirvish/llms.txt Use the `fd` command for fast file searches within the current directory or a specified path. Configure default `fd` switches like `--hidden` to include hidden files. ```elisp ;; Search in current directory (dirvish-fd default-directory "") ``` ```elisp ;; Search with pattern (dirvish-fd "~/Projects" "test") ``` ```elisp ;; Bind to key (define-key dirvish-mode-map (kbd "/") 'dirvish-fd) ``` ```elisp ;; Configure default fd switches (setq dirvish-fd-switches "--hidden") ``` -------------------------------- ### Set Dirvish Icon Height for All-The-Icons Source: https://github.com/alexluigit/dirvish/blob/main/docs/EXTENSIONS.org Configure the height of icons from the `all-the-icons` backend using `dirvish-all-the-icons-height`. ```emacs-lisp dirvish-all-the-icons-height ``` -------------------------------- ### Configure Dirvish Mode Line and Header Line Source: https://github.com/alexluigit/dirvish/blob/main/docs/CUSTOMIZING.org Adjust the placement, height, and content of Dirvish's mode line and header line by setting variables like `dirvish-use-header-line`, `dirvish-mode-line-bar-image-width`, `dirvish-header-line-height`, `dirvish-mode-line-height`, `dirvish-header-line-format`, and `dirvish-mode-line-format`. ```emacs-lisp ;; Placement ;; (setq dirvish-use-header-line nil) ; hide header line (show the classic dired header) ;; (setq dirvish-use-mode-line nil) ; hide mode line (setq dirvish-use-header-line 'global) ; make header line span all panes (setq dirvish-mode-line-bar-image-width 0) ; hide the leading bar image ;; Height ;;; '(25 . 35) means ;;; - height in single window sessions is 25 ;;; - height in full-frame sessions is 35 (setq dirvish-header-line-height '(25 . 35)) (setq dirvish-mode-line-height 25) ; shorthand for '(25 . 25) ;; Segments ;;; 1. the order of segments *matters* here ;;; 2. it's ok to place raw strings in it as separators (setq dirvish-header-line-format '(:left (path) :right (free-space))) dirvish-mode-line-format '(:left (sort file-time " " file-size symlink) :right (omit yank index))) ``` -------------------------------- ### Navigate Recent Directories Source: https://context7.com/alexluigit/dirvish/llms.txt Jump to recently visited directories within the current Emacs session using `dirvish-history-jump`. Navigate forward and backward through the history, or go to the most recent Dirvish buffer. ```elisp ;; Jump to history entry (dirvish-history-jump) ``` ```elisp ;; Navigate forward/backward in session history (dirvish-history-go-forward) (dirvish-history-go-backward) ``` ```elisp ;; Go to most recent Dirvish buffer (dirvish-history-last) ``` ```elisp ;; Bind navigation keys (define-key dirvish-mode-map (kbd "M-f") 'dirvish-history-go-forward) (define-key dirvish-mode-map (kbd "M-b") 'dirvish-history-go-backward) ``` -------------------------------- ### dirvish-mode-line-format Source: https://context7.com/alexluigit/dirvish/llms.txt Configure segments displayed in the mode line at the bottom of directory panes. ```APIDOC ## dirvish-mode-line-format ### Description Configure segments displayed in the mode line (bottom of directory panes). ### Request Example (setq dirvish-mode-line-format '(:left (sort symlink) :right (omit yank index))) ``` -------------------------------- ### Configure Large Directory Threshold for fd Source: https://context7.com/alexluigit/dirvish/llms.txt Automatically use `fd` for directories exceeding a specified file count threshold to improve performance. Set to `nil` to disable this feature. ```elisp ;; Use fd for directories with more than 20000 files (setq dirvish-large-directory-threshold 20000) ``` ```elisp ;; Disable auto-fd (setq dirvish-large-directory-threshold nil) ``` -------------------------------- ### Toggle Directory Subtree Expansion Source: https://context7.com/alexluigit/dirvish/llms.txt Toggle the inline expansion of directories to view their contents as subtrees. This feature can be bound to a key, such as `TAB`, and can display expansion state indicators. ```elisp ;; Toggle directory under cursor as subtree (dirvish-subtree-toggle) ``` ```elisp ;; Bind to TAB (define-key dirvish-mode-map (kbd "TAB") 'dirvish-subtree-toggle) ``` ```elisp ;; Show expansion state indicator (add-to-list 'dirvish-attributes 'subtree-state) ``` -------------------------------- ### dirvish-define-attribute Source: https://context7.com/alexluigit/dirvish/llms.txt Macro to define custom file attributes for rendering in the file listing. ```APIDOC ## dirvish-define-attribute ### Description Macro to define custom file attributes for rendering in the file listing. ### Request Example (dirvish-define-attribute my-extension "Show file extension in brackets." :width 10 (when-let* ((ext (file-name-extension f-name))) `(right . ,(propertize (format "[%s]" ext) 'face 'font-lock-comment-face)))) ```