Last active
December 10, 2015 22:08
-
-
Save sluchin/4499511 to your computer and use it in GitHub Desktop.
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
;; tar + gzip で圧縮 | |
(when (and (executable-find "tar") (executable-find "gzip")) | |
(defun dired-do-tar-gzip (arg) | |
"Execute tar and gzip command" | |
(interactive "P") | |
(let ((files (dired-get-marked-files t current-prefix-arg))) | |
(let ((filename (read-string (concat "Filename(" (car files) ".tar.gz): ")))) | |
(when (string= "" filename) | |
(setq filename (concat (car files) ".tar.gz"))) | |
(when (not (string-match | |
"\\(\\.tar\\.gz\\)$\\|\\(\\.tgz\\)$" filename)) | |
(setq filename (concat filename ".tar.gz"))) ; 拡張子追加 | |
(or (when (member filename (directory-files default-directory)) | |
(not (y-or-n-p | |
(concat "Overwrite `" filename "'? [Type yn]")))) ; 同名ファイル | |
(when (not (dired-do-shell-command | |
(concat "tar cfz " filename " *") nil files)) | |
(message (concat "Execute tar command to `" filename "'...done"))))))) | |
(define-key dired-mode-map (kbd "C-c z") 'dired-do-tar-gzip)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment