Search code examples
emacsdired

Customizing dired


I just came across this dired mode screen at Wikipedia. I am looking into those customizations.

Regarding colors, I guess just specifying the correct faces will do, but how do I get dired to show file sized in kbytes by default? And the available space in MBs (top line)?


Solution

  • To get the file sizes in kbytes, you can customize the variable dired-listing-switches to use the -k option:

    (setq dired-listing-switches "-alk")
    

    You have to do a little more work to get the total/available numbers in MB. This worked on my Linux system, but the available portion failed to work on my Windows box:

    (setq directory-free-space-args "-Pm")
    (defadvice insert-directory (after insert-directory-adjust-total-by-1024 activate)
      "modify the total number by dividing it by 1024"
      (save-excursion
    (save-match-data
      (goto-char (point-min))
      (when (re-search-forward "^ *total used in directory \\([0-9]+\\) ")
        (replace-match (number-to-string (/ (string-to-number (match-string 1)) 1024)) nil nil nil 1)))))