Skip to content

Latest commit

 

History

History
161 lines (112 loc) · 7 KB

dired.org

File metadata and controls

161 lines (112 loc) · 7 KB

❮ Back to Casual

Casual Dired

An opinionated Transient-based user interface for the Emacs file manager Dired.

images/casual-dired-screenshot.png

Requirements

Casual Dired requires that the ls utility from GNU coreutils ≥ 8.32 be installed.

The following links provide guidance for installing GNU coreutils on different platforms.

macOS

Note that the default packaged ls on macOS is BSD-flavored which is not supported by Casual Dired. Users wishing to use Casual Dired on macOS are recommended to install GNU coreutils and configure their Emacs to point to its version of ls accordingly.

Windows

For users running on Microsoft Windows, use this guidance to configure Emacs to use an external install of ls.

Install

If installed via MELPA then add these lines to your Emacs initialization file with your binding of preference.

(require 'casual-dired) ; optional if using autoloaded menu
(keymap-set dired-mode-map "C-o" #'casual-dired-tmenu)
(keymap-set dired-mode-map "s" #'casual-dired-sort-by-tmenu) ; optional
(keymap-set dired-mode-map "/" #'casual-dired-search-replace-tmenu) ; optional

In addition to binding the main menu casual-dired-tmenu, the user can also bind the sort-by menu casual-dired-sort-by-tmenu and the search & replace menu casual-dired-search-replace-tmenu.

Included is a standard keymap for Dired sorting commands (casual-dired-sort-menu) which can be included in a context menu for a mouse-driven workflow. An example of this is shown below:

(require 'casual-dired)

(defun casual-dired-context-menu-addons (menu click)
  "Customize context MENU with CLICK event."
  (easy-menu-add-item menu nil casual-dired-sort-menu)
  menu)

(add-hook 'context-menu-functions #'casual-dired-context-menu-addons)
(add-hook 'dired-mode-hook 'context-menu-mode)

Configuration

As Dired has been around for a long time, the different ways of configuring it are myriad. Described below is a configuration used by the author that is consistent with the bindings used in Casual Dired.

Initialization

(require 'dired)
(require 'dired-x)
(require 'wdired)
(require 'hl-line)
(require 'mouse)
(require 'image-dired)
(require 'image-dired-dired)
(require 'casual-dired)

(keymap-set dired-mode-map "C-o" #'casual-dired-tmenu)
(keymap-set dired-mode-map "s" #'casual-dired-sort-by-tmenu)
(keymap-set dired-mode-map "/" #'casual-dired-search-replace-tmenu)

(add-hook 'dired-mode-hook 'hl-line-mode)
(add-hook 'dired-mode-hook 'context-menu-mode)
(add-hook 'dired-mode-hook 'dired-async-mode)
(add-hook
 'dired-mode-hook
 (lambda ()
   (setq-local mouse-1-click-follows-link 'double)))

(keymap-set dired-mode-map "M-o" #'dired-omit-mode)
(keymap-set dired-mode-map "E" #'wdired-change-to-wdired-mode)
(keymap-set dired-mode-map "M-n" #'dired-next-dirline)
(keymap-set dired-mode-map "M-p" #'dired-prev-dirline)
(keymap-set dired-mode-map "]" #'dired-next-subdir)
(keymap-set dired-mode-map "[" #'dired-prev-subdir)
(keymap-set dired-mode-map "A-M-<mouse-1>" #'browse-url-of-dired-file)
(keymap-set dired-mode-map "<backtab>" #'dired-prev-subdir)
(keymap-set dired-mode-map "TAB" #'dired-next-subdir)
(keymap-set dired-mode-map "M-j" #'dired-goto-subdir)
(keymap-set dired-mode-map ";" #'image-dired-dired-toggle-marked-thumbs)

(keymap-set image-dired-thumbnail-mode-map "n" #'image-dired-display-next)
(keymap-set image-dired-thumbnail-mode-map "p" #'image-dired-display-previous)

Variables

Casual Dired offers a settings menu to customize a set of commonly used Dired variables. Use this to customize your Dired behavior to taste.

images/casual-dired-settings-screenshot.png

If you have GNU ls installed and configured, use the l key to set the variable dired-use-ls-dired to t (“Use GNU ‘ls’ with –dired”). Otherwise this should be disabled.

Unicode Symbol Support

By enabling “Use Unicode Symbols” from the Settings menu, Casual Dired will use Unicode symbols as appropriate in its menus. An example is shown below.

images/casual-dired-screenshot-unicode.png

To ensure proper layout and spacing, your default typeface should be fixed-width or monospace and must support the Unicode symbols used.

Usage

  1. Invoke M-x dired to launch Dired.
  2. When the point is in the Dired window, invoke C-o (or a binding of your choosing) to launch the Casual Dired menu.

Enhanced Sorting

Casual Dired offers enhanced sorting capabilities through GNU ls. Use this to sort your Dired buffer to preference. Filter dot files (.*) by disabling the --all option is available here.

images/casual-dired-sort-by-screenshot.png

With the Sort By menu raised, one can save the switch settings for future use via the binding C-x C-s (transient-save). Note this is a global setting and will apply to all future calls to the Sort By menu.

Search & Replace

Search and replace in multiple marked files using the / Search & Replace menu item. This will raise a menu of Dired commands that will work on marked files.

images/casual-dired-search-replace.png

While most Dired commands use Emacs-style regular expression syntax, there are two commands that instead take instead grep-style syntax:

  • (g) Find regex… (dired-do-find-regexp)
  • (G) Find regex and replace… (dired-do-find-regexp-and-replace)

The grep-style syntax is dependent on the grep implementation that is installed and used by Emacs.

Bulk Dired Operations

Casual Dired organizes a number of Dired commands that work on a set of marked files. These commands are presented in the Utils menu.

images/casual-dired-utils-screenshot.png

Link

Create symbolic and hard links via the Link menu. Both absolute and relative symbolic links (symlinks) are supported.

images/casual-dired-link.png

Sponsorship

If you enjoy using Casual Dired, consider making a modest financial contribution to help support its development and maintenance.

images/default-yellow.png

See Also