我想在dired或类似dired的缓冲区中运行解压缩(甚至zip).有这样的事吗?我想要与Nautilus文件管理器类似的东西:即,选择文件,然后按一下键击以将这些文件放入新的存档文件中.
谢谢
你有选择......
要解压缩.zip文件,只需添加到变量即可 'dired-compress-file-suffixes
(eval-after-load "dired-aux" '(add-to-list 'dired-compress-file-suffixes '("\\.zip\\'" ".zip" "unzip")))
现在Z
,dired中的密钥将识别.zip扩展并解压缩.zip存档.已经支持是gunzip
,bunzip2
,uncompress
和dictunzip
.
如果要标记文件并将其添加到.zip存档,可以使用以下命令对z
已标记文件集进行压缩:
(eval-after-load "dired" '(define-key dired-mode-map "z" 'dired-zip-files)) (defun dired-zip-files (zip-file) "Create an archive containing the marked files." (interactive "sEnter name of zip file: ") ;; create the zip file (let ((zip-file (if (string-match ".zip$" zip-file) zip-file (concat zip-file ".zip")))) (shell-command (concat "zip " zip-file " " (concat-string-list (mapcar '(lambda (filename) (file-name-nondirectory filename)) (dired-get-marked-files)))))) (revert-buffer) ;; remove the mark on all the files "*" to " " ;; (dired-change-marks 42 ?\040) ;; mark zip file ;; (dired-mark-files-regexp (filename-to-regexp zip-file)) ) (defun concat-string-list (list) "Return a string which is a concatenation of all elements of the list separated by spaces" (mapconcat '(lambda (obj) (format "%s" obj)) list " "))
要压缩文件,请在dired中打开目录.标记要压缩的文件m
.然后输入
! zip foo.zip *
要从dired中提取整个存档,您可以标记文件并运行& unzip
,就像在shell中一样.
zip-archive模式允许您以类似方式浏览zip文件.它应该附带最新版本的GNU emacs,并且在您访问扩展名为.zip的文件时将默认使用.在这种模式下,您可以将单个文件提取到缓冲区中,然后从中保存C-x C-s
.