5

What options are there to change the view of a directory in emacs dired mode? How to apply it? How can I change it on the fly?

In particular I want to know:

  • How to make it show the file sizes in human readable format (MB, GB, ...)?
  • How to omit the permissions, owner and group in the list view?
  • How to change appearance of symbolic links? (I want it to be displayed like regular files i.e. without the target, but in another color to indicate that they are links).
Kevdog777
  • 3,194
  • 18
  • 43
  • 64
student
  • 17,875
  • 31
  • 103
  • 169
  • 1
    For human readable file sizes, check http://stackoverflow.com/a/2859033/605276 and also check the Dired+ package – Juancho Aug 06 '12 at 12:45
  • 1
    Yes, read `man ls` and then experiment with the options to make ls work the way you want Dired to list files. Then, put (for example) this in `.emacs`: `(setq dired-listing-switches "-lBhX")` Human readable is `ls -h`, so that is the `h`. (I suppose `-l` is highly recommended. The rest is just what I use.) – Emanuel Berg Aug 06 '12 at 14:58
  • @EmanuelBerg Thanks, then the `ls` option `-gohL` would be closest to have what I wanted... Do you know how to hide also the permissions and how I can apply this on the fly without editing my `.emacs` file? – student Aug 06 '12 at 16:19
  • About permissions, I don't know. About on the fly, `M-x set-variable RET dired-listing-switches RET "-gohL"`, then `M-x dired` (or `C-x d`) to see the result. Also, you could put several lines like this `(setq dired-listing-switches "-lBhX")` (with different options) in `*scratch*`, then, with the cursor just to the right of the right parenthesis, hit `C-x C-e`. This will probably give you even faster testing. – Emanuel Berg Aug 06 '12 at 20:15
  • @EmanuelBerg Can you convert your comment into an answer, then I can accept it (even though it doesn't solve the permission question)? – student Aug 07 '12 at 12:03
  • What's the urgency? It is better the question is open until everything is resolved. Not to forget, **you** might be able to give a full answer (get away with the permissions) in just a few weeks. But I'm happy I could help you, my pleasure :) – Emanuel Berg Aug 07 '12 at 12:17
  • @EmanuelBerg I agree with you and think that the question should be open until everything is resolved. However I just got several times the advice to work on my accepting rate... since then I try to accept faster and also answers which do not solve the problem in every detail – student Aug 07 '12 at 12:33
  • @student: I read `man ls` the other day and found something interesting: "`-D`, `--dired` generate output designed for Emacs' dired mode" – Emanuel Berg Aug 08 '12 at 19:28

1 Answers1

3

Remember that in dired mode, the s option will toggle the sort order, but with a prefix argument, will let you change the switch to ls.

From http://www.gnu.org/software/emacs/manual/html_node/emacs/Dired-Updating.html:

C-u s switches <RET> lets you specify a new value for dired-listing-switches.

So when I want human-readable sizes listed in my dired buffer, I type:

C-u s -lah <enter>

and you'll see what you need. Ditto for any other options to ls.

ckhan
  • 4,132
  • 22
  • 21