How do I hide number of links in dired?

痞子三分冷 提交于 2019-12-07 23:58:12

问题


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.


回答1:


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 tols' for listing the directory; this string must contain -l'. If you use a numeric prefix argument with thedired' command, you can specify the ls' 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='.




回答2:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!