Search code examples
emacsdired

Emacs: extending dired-do-compress to directories


If I press 'Z' in dired (or x-dired) mode in emacs, the file under the cursor is compressed or uncompressed.

I'd like to extend this behavior to directories. That is, if the cursor is at a directory "stuff", I'd like 'Z' to run

tar -zcf stuff.tgz stuff

(on the assumption that 'tar' is provided by the OS).

Side note: The converse (expanding stuff.tgz into the full directory tree) can already be done by '!', which suggests guesses for expansion. The asymmetry ('Z' to compress and '!' to uncompress) does not bother me.


Solution

  • The following is a link to the library dired-tar -- it tars and compresses directories and files. I have verified it works on OSX with a recent version of Emacs Trunk built on March 19, 2014.

    http://www.emacswiki.org/emacs/DiredTar