GitHub - alexluigit/dirvish: Dired should be a nice file manager.
source link: https://github.com/alexluigit/dirvish
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Dirvish
Wish you a better dired.
Introduction
Dirvish is a minimalistic file manager based on dired. This package tries to empower dired by giving it a modern user interface, in the meantime, preserves its customizability. Emacs users deserve a file manager that is even better than those popular ones such as ranger, vifm, lf since it is not limited to a terminal.
The name dirvish is a tribute to vim-dirvish.
Dependencies
PackageDescriptionRequired
exa
For directory previewYes
all-the-icons.el
Icon supportOptional
pdftoppm
Generate pdf preface imageOptional
imagemagick
Generate image cacheOptional
ffmpegthumbnailer
Generate video thumbnailerOptional
epub-thumbnailer
Generate epub thumbnailerOptional
zipinfo
Preview zip filesOptional
mediainfo
Show information for audio filesOptional
Installation
Dirvish is available from Melpa.
For package.el
user
You can install it directly via package-install
if you have melpa in your package-archives
.
For straight.el
user
(straight-use-package 'dirvish)
Alternatively, install it by using use-package and straight in tandem.
(use-package dirvish :straight t)
Manual install
To install it manually, first clone this repository,
git clone https://github.com/alexluigit/dirvish
then add path/to/dirvish
to your load-path
.
(add-to-list 'load-path "/path/to/dirvish") (require 'dirvish)
Quickstart
After installation, just M-x
and run dirvish
.
Since dirvish-mode
is just a major-mode
derived from dired-mode
, it respects all
of your dired config (including keymapping) in principle.
As an example, here is an excerpt from my personal dired config:
(setq dired-kill-when-opening-new-dired-buffer t) ; added in emacs 28 (setq dired-clean-confirm-killing-deleted-buffers nil) (setq dired-recursive-copies 'always) (setq dired-recursive-deletes 'always) (setq delete-by-moving-to-trash t) (setq dired-dwim-target t) (setq dired-listing-switches "-AGhlv --group-directories-first --time-style=long-iso")
Features
File preview
When dirvish-enable-preview
is non-nil, a preview window showing the content of
selected file/directory will be displayed at right side of dirvish frame.
Debouncing
Reduce unnecessary UI redraw.
Native GIF supportNavigate to a GIF file in Dirvish and check out the preview window.
Image cacheA image cache file, with small filesize that is unlikely to block Emacs when rendering, is generated when the original image file is larger than 500KB.
Highly customizableA preview buffer is created either by an elisp function or by the help of a
shell command. If you don’t like the way dirvish creates the preview buffer
for certain file types, take a look at dirvish-preview-cmd-alist
. This
variable determines how a preview buffer get generated for different file
types, customize it to suit your need. See Dirvish wiki_TODO for more details.
More intuitive file operation
Dired is superb, but from a modern file manager’s (like ranger, lf) perspective, it lacks some abilities when it comes file operation, such as:
- You can not mark files/directory across multiple dired buffers (by default)
- You can not paste/move files without specify the target directory explicitly (input in minibuffer)
Whereas with dirvish, you can:
- Marking files across multiple dirvish buffers
- Paste/move marked files/directory to current directory with one keystroke
Asynchronous I/O
To prevent emacs from getting freezes, dirvish uses external process to deal with heavy I/O task, such as file copy/move, directory preview, or image cache generation etc.
Bulit-in icon support
You don’t need all-the-icons-dired anymore since dirvish have built-in icon support. This native icon solution has several advantages over dired + all-the-icons-dired, those are:
- it handles line highlighting nicely (all-the-icons-dired doesn’t play well
with
hl-line-mode
). - it doesn’t render icon for all the files in a directory eagerly, instead it
only render icons that are displayed within the viewport. (Try visiting
/usr/bin
or any directory with over 1000 files using both dirvish or dired + all-the-icons-dired to see the difference.)
“Dirvish-ish” dired
Usually dirvish
takes up the whole frame, but sometimes we prefer managing files
inside current window, just like how dired does it. To enable a single window
dirvish, you can either:
Enable it once
(dirvish nil t)
Enable it automatically everytime you invoke dired-jump
(dirvish-override-dired-jump)
A glimpse of single-window dirvish:
Minibuffer file preview (extension)
dirvish-minibuffer-preview.el is an extension for dirvish, it provides
dirvish-minibuf-preview-mode
, which is a feature to preview file when narrowing
file/directory candidates using minibuffer.
Why does this feature exist?
Dirvish and minibuffer seem unrelated at first glance. But when it comes to display a file preview, they actually share the same mechanism, that is: get file path under the cursor and update preview window accordingly. Displaying minibuffer file preview in a “dirvish” way, not only a lot of source code can be reused, but also related user configurations. In other words, you don’t have to configure file preview for dirvish and for minibuffer separately, they will always display the same thing.
For selectrum or vertico users (only support these 2 completion UIs for now), if you’d like to give this extension a try, all you need is:
(require 'dirvish-minibuffer-preview) (dirvish-minibuf-preview-mode)
Check out this YOUTUBE_VIDEO_UPLOAD_TODO and Dirvish wiki_TODO for more details.
Configuration
See Dirvish wiki_TODO for all customization options.
Similar projects
Ranger.el
This package is inspired a lot by ranger.el, thanks @ralesi for bringing in ranger to emacs!
Although these 2 packages have something in common, unlike ranger.el, which tries to become an all-around emulation of ranger, dirvish is more bare-bone (roughly 1.2 kLOC), meaning it does NOT try to port all “goodness” from ranger. Instead, it only tries to:
- provides a better dired UI
- support preview for directory and common file types.
- improve some dired commands, make them more intuitive and accesible.
And here are some specific differences between dirvish and ranger.el:
- Highlight current line / Icons
Ranger uses
Ranger + hl-line-mode + all-the-icons-dired-modehl-line-mode
to highlight current line, but this minor-mode doesn’t play very well withall-the-icons-dired-mode
.
Dirvish - Header display
Ranger uses
Rangerheader-line-format
to display its header, this approach leads to misaligned/mismatched header string when you have multiple parent windows. In contrast, dirvish uses posframe for that purpose.
Dirvish - Preview buffer
Ranger uses dired for creating both parent buffers and directory preview buffer, which causes a lot of undesirable behaviours. Because when you have multiple ranger instance running, a ranger buffer can be both a parent buffer in INSTANCE-1 and a preview buffer in INSTANCE-2. In this case, update INSTANCE-1 inevitably mutate the state of INSTANCE-2, which is definitely not what we want.
In ranger, it’s quite difficult to customize the setup of a preview buffer. The reason is, again, a preview buffer can either be a dired buffer or Non-dired buffer.
To avoid this confusion, dirvish use external shell command (
exa
by default) for directory preview, so a preview buffer would never be a dired buffer. Also, you can customize the setup for preview buffer withdirvish-preview-setup-hook
anddirvish-preview-cmd-alist
. - Keybindings
Dirvish does not introduce any keybindings by default, see
dirvish-mode-map
for more details.
Neotree.el
Issues
- You may experience some issue with Windows since dirvish has not been tested on it
- It might have conflicts with packages that controls window placement.
- GIF may fail to play due to large filesize.
Feel free to report issues.
Copying
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK