Created
October 4, 2013 15:53
-
-
Save KeenS/6828197 to your computer and use it in GitHub Desktop.
A dired-mode extension to archive files marked. To use, mark files with `m` and then `T`. Notice that you can uncompress and/or expand wth `!` default command (`tar xzvf`).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun dired-tar (tarname files &optional arg) | |
"A dired-mode extension to archive files marked. With prefix argument, the tarball is gziped." | |
(interactive (let ((files (dired-get-marked-files))) | |
(list (read-string "Tarball name: " (concat (file-relative-name (car files)) ".tar.gz")) | |
files "P"))) | |
(let ((tar (if arg | |
(if dired-guess-shell-gnutar | |
(concat dired-guess-shell-gnutar " zcf %s %s") | |
"tar cf - %2s | gzip > %1s") | |
"tar cf %s %s"))) | |
(shell-command (format tar tarname (mapconcat 'file-relative-name files " "))))) | |
(add-hook 'dired-load-hook (lambda () (define-key dired-mode-map "T" 'dired-tar))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment