99.9% of the time, I don't care how many links are pointing to a file. How do I get dired (or alternatively, ls) to not display the number of links?
For reference, the output of ls -l is something like:
-rw-rw-rw- 1 root dir 104 Dec 25 19:32 file
The number of links, in this case, is 1. ls has a flag to remove the group number (104) but not one to remove the number of links, from what I can tell.
I'm afraid editing the format will screw up dired's parsing, as ls has a special flag for producing output to dired.
To control how things are displayed in dired, you can customize the variable dired-listing-switches
. However, as you noted, not displaying the number of links is not an option.
A slightly different approach would be to use the package dired-details
, which hides all details until you want them. This hides the number of links (but also hides other information). Follow the link to find the package (and a dired-details+
which sounds like it fixes a couple minor inconveniences with dired-details
).
Original answer information follows:
(setq dired-listing-switches "-l")
From the "Entering Dired" info page:
The variable
dired-listing-switches' specifies the options to give to
ls' for listing the directory; this string must contain-l'. If you use a numeric prefix argument with the
dired' command, you can specify thels' switches with the minibuffer before you enter the directory specification. No matter how they are specified, the
ls' switches can include short options (that is, single characters) requiring no arguments, and long options (starting with--') whose arguments are specified with
='.
You can use ls-lisp
to customize the dired buffer display. ls-lisp
is part of GNU Emacs (22.1 or perhaps even earlier) ls-lisp
has a ls-lisp-verbosity
customize variable that will allow you to show/hide "links", "uid" and "gid". It also has other things that may tickle your customize fancy.
I like ls-lisp
so much I use it everywhere, on my Windows and even Linux sessions.
来源:https://stackoverflow.com/questions/1878129/how-do-i-hide-number-of-links-in-dired