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)?
I came up with the same problem and found how to change swithes on the fly.
So while in a dired buffer
C-u s
you can now change switches used by ls. Add h
do get a human readable file sizes
You can add other switches too, for example I changed it to -alsh
and it now sorts by file size
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)))))
Actually, that screenshot is almost certainly of Dired+, though the accompanying text gives the impression that it is from vanilla Emacs (XEmacs?), and the attribution for the screenshot is "Emacs development team".
So yes, the answer is that you can easily get that appearance, by using Dired+ and simply customizing the default faces: M-x customize-group Dired-Plus
.
You didn't ask, but I thought I'd add....
I wanted to be able to easily sort the dired output by size and extension, as well as name and time. I know I can do this with M-x universal-argument dired-sort-toggle-or-edit
, but I wanted it available on the s
key to make it quick.
;; Redefine the sorting in dired to flip between sorting on name, size,
;; time, and extension, rather than simply on name and time.
(defun dired-sort-toggle ()
;; Toggle between sort by date/name. Reverts the buffer.
(setq dired-actual-switches
(let (case-fold-search)
(cond
((string-match " " dired-actual-switches) ;; contains a space
;; New toggle scheme: add/remove a trailing " -t" " -S",
;; or " -U"
(cond
((string-match " -t\\'" dired-actual-switches)
(concat
(substring dired-actual-switches 0 (match-beginning 0))
" -X"))
((string-match " -X\\'" dired-actual-switches)
(concat
(substring dired-actual-switches 0 (match-beginning 0))
" -S"))
((string-match " -S\\'" dired-actual-switches)
(substring dired-actual-switches 0 (match-beginning 0)))
(t
(concat dired-actual-switches " -t"))))
(t
;; old toggle scheme: look for a sorting switch, one of [tUXS]
;; and switch between them. Assume there is only ONE present.
(let* ((old-sorting-switch
(if (string-match (concat "[t" dired-ls-sorting-switches "]")
dired-actual-switches)
(substring dired-actual-switches (match-beginning 0)
(match-end 0))
""))
(new-sorting-switch
(cond
((string= old-sorting-switch "t")
"X")
((string= old-sorting-switch "X")
"S")
((string= old-sorting-switch "S")
"")
(t
"t"))))
(concat
"-l"
;; strip -l and any sorting switches
(dired-replace-in-string (concat "[-lt"
dired-ls-sorting-switches "]")
""
dired-actual-switches)
new-sorting-switch))))))
(dired-sort-set-modeline)
(revert-buffer))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With