Xah Dired Toggle Human Readable File Size 🚀

By Xah Lee. Date: .

Toggle Human Readable File Size

(defun xah-dired-toggle-human-readable-size ()
  "Toggle human readable file size format in current `dired' buffer.
You may need to call it twice to see change.

URL `http://xahlee.info/emacs/emacs/emacs_dired_toggle_human_readable_file_size.html'
Created: 2024-07-13
Version: 2024-07-19"
  (interactive)
  (when (eq major-mode 'dired-mode)
    (let ((xflag (get 'xah-dired-toggle-human-readable-size 'human-readable)))
      (if (or (eq xflag nil) (eq xflag 0))
          (progn
            (dired default-directory "-alh")
            (put 'xah-dired-toggle-human-readable-size 'human-readable 1))
        (progn
          (dired default-directory "-al")
          (put 'xah-dired-toggle-human-readable-size 'human-readable 0))))))

Emacs Dired, File Management