質問

diredまたはdiredに似たバッファ内でunzip(またはzip)を実行したいと思います。このようなものはありますか? Nautilusファイルマネージャーと同じようなものが必要です。つまり、ファイルを選択し、キーストロークを押してこれらのファイルを新しいアーカイブファイルに入れます。

ありがとう

役に立ちましたか?

解決

オプションがあります...

.zipファイルを解凍するには、変数 'dired-compress-file-suffixes

に追加するだけです。
(eval-after-load "dired-aux"
   '(add-to-list 'dired-compress-file-suffixes 
                 '("\\.zip\\'" ".zip" "unzip")))

diredの Z キーは.zip拡張子を認識し、.zipアーカイブを解凍します。既にサポートされているのは、 gunzip bunzip2 uncompress 、および dictunzip です。

ファイルをマークして.zipアーカイブに追加する場合は、次を使用して z をマークされたファイルのセットをzipにバインドできます。

(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<*>quot; 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でディレクトリを開きます。 zip圧縮するファイルを m でマークします。次に入力します

! zip foo.zip * <RET>

diredからアーカイブ全体を抽出するには、ファイルにマークを付けて&amp;を実行します。シェルで行うのと同じように、を解凍します。

zip-archiveモードでは、zipファイルをdiredのように閲覧できます。 GNU emacsの最新バージョンに付属している必要があり、拡張子が.zipのファイルにアクセスするとデフォルトで使用されます。このモードから個々のファイルをバッファに抽出し、そこから C-x C-s で保存できます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top