Using dired as a file manager in Emacs

Dired is a built-in feature of Emacs that builds a file listing and allows you
to see/modify/open/etc files that are in a directory.

One of the great things about it is that it also supports all of the
abstractions that Emacs does, like TRAMP for accessing remote machines.

You might have seen it if you open a directory with find-file by accident
instead of a file, but you can invoke it manually by doing M-x dired-jump. It
defaults to the current directory. By default, you can also hit C-x d and be
prompted for where to open a dired buffer.

(I like to bind dired-jump to C-x C-j but that's just my preference)

Key

Action

C-x d

Prompt for directory and open dired there

Once inside of dired, you can navigate and perform actions with the following:
(this is a subset that I find the most useful)

Key

Action

n/p

next-line/previous-line

RET

open a file or directory

f

open the file

e

open the file

o

open the file in the other window (alongside)

!

perform a shell function on the file

&

perform a shell function asynchronously on the file

(

hide/unhide details for the listing

+

prompt to create a directory

Z

compress or uncompress file at point

g

refresh buffer

i

insert the sub-directory at point

m

mark a file to do something on it later

C

copy the file to a location

R

rename/move the file to a location

D

delete the file

d

mark a file to be deleted

x

perform the deletion of the files that are marked as deleted

M

chmod a file (change permissions)

O

chown a file (change owner)

G

chgrp a file (change group)

q

quit/close the dired window

u

unmark a file

U

unmark all files

DEMO

Customizing Dired

Dired has a bunch of options, here are some that I like setting

dired-listing-switches

This changes the switches that are passed to the ls command when a dired
buffer has been generated. On Linux I like to set mine to:

gls is the GNU version of ls that can be installed, if it doesn't exist I
fall back to a different set of switches (just on OSX).

ls-lisp-dirs-first

By default dired will list files and directories in alphabetical order. If you
would rather have directories at the top of the file and files below, you can
set ls-lisp-dirs-first to t and they will always be at the top.

(setq ls-lisp-dirs-first t)

Recursive copying and deleting

When deleting or copying files, you can have dired default to acting recursively
by setting:

dired-aux

Also built into Emacs, this is what provides the chgrp, chown, chmod
functionality as well as some other builtins

(require'dired-aux)

wdired

Another awesome extension for Dired that's built into Emacs, this makes the
dired buffer writable, you can hit C-x C-q to enter the mode, make your
changes and then hit C-c C-c to apply them, or C-c ESC to discard them.

DEMO

dired+

Dired+ provides additional fontification (colors), enhances some of the existing
functionality (like the i command), allows operating on all files or files and
directories in the directory and adds the diredp-hide-details-initially-flag
that allows hiding or showing details automatically when opening new Dired
buffers.

dired-narrow

The dired-narrow function (which hails for the dired-hacks project) allows you
to narrow a dired buffer to only files that match a particular name. I like to
bind it to / in my config

Asynchronous Dired

You can make the copy and rename/move commands in dired by installing the
async package. From there, all you need to do is:

(require'dired-async)

And the commands will automatically by asynchronous

quick-preview

Not dired-specific per-se, but quick-preview is great for files that Emacs might
not be able to open, but your regular X11 (or OSX's quick preview) can show
well, like moves are things. Works great when you're in a dired buffer to
preview a file.