Commit faa3a0585de8

Vincent Demeester <vincent@sbr.pm>
2015-04-01 13:45:57
Add a dired-get-size shortcut
1 parent 67c3846
Changed files (1)
.emacs.d
.emacs.d/emacs.org
@@ -488,7 +488,6 @@
      First load =dired-x= and set a list of default guess when issuing
      =!= (=dired-do-shell-command=) or =&= (=dired-do-async-shell-command=).
 
-
      #+BEGIN_SRC emacs-lisp
        (use-package dired-x)
        (setq dired-guess-shell-alist-user
@@ -505,6 +504,15 @@
                   ("\\.cue?\\'" "audacious")))
      #+END_SRC
 
+     Install dired+.
+
+     #+BEGIN_SRC emacs-lisp
+       (setq diredp-hide-details-initially-flag nil)
+       (use-package dired+
+                    :ensure t
+                    :init)
+     #+END_SRC
+
      Then, use nohup to not attach a process to emacs.
 
      #+BEGIN_SRC emacs-lisp
@@ -537,12 +545,20 @@
        (define-key dired-mode-map "c" 'dired-start-process)
      #+END_SRC
 
+     Let's also add a command to display the size of marked files.
 
      #+BEGIN_SRC emacs-lisp
-       (setq diredp-hide-details-initially-flag nil)
-       (use-package dired+
-                    :ensure t
-                    :init)
+       (defun dired-get-size ()
+         (interactive)
+         (let ((files (dired-get-marked-files)))
+           (with-temp-buffer
+             (apply 'call-process "/usr/bin/du" nil t nil "-schL" files) ;; -L to dereference (git-annex folder)
+             (message
+              "Size of all marked files: %s"
+              (progn
+                (re-search-backward "\\(^[ 0-9.,]+[A-Za-z]+\\).*total$")
+                (match-string 1))))))
+       (define-key dired-mode-map (kbd "z") 'dired-get-size)
      #+END_SRC
 
      Customize a bit the dired buffer