dired
Основной файловый менеджер емакса. Опять же, случайная куча случайно прихваченного.
- dired сортирует файлы по датам, если ему сказать s.
- https://github.com/jojojames/dired-sidebar - dired-sidebar - каталог в сайдбаре
- http://ergoemacs.org/emacs/file_management.html
- http://ergoemacs.org/emacs/dired_sort.html
- https://www.emacswiki.org/emacs/DiredOmitMode - (скрывание и раскрашивание)
- http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html
- http://ergoemacs.org/emacs/emacs_dired_tips.html
- http://ergoemacs.org/emacs/keyboard_shortcuts.html
rename multiple files in emacs,
the most easy way is:
Alt+x dired to go to the directory. Alt+x dired-toggle-read-only 【Ctrl+x Ctrl+q】. Then, just edit the file names. When done, wdired-finish-edit 【Ctrl+c Ctrl+c】 to commit the changes. To abort, Alt+x wdired-abort-changes 【Ctrl+c Ctrl+k】.
You can use find replace when in edit mode. For example, Alt+x query-replace or Alt+x query-replace-regexp. http://ergoemacs.org/emacs/rename_file_pattern.html http://ergoemacs.org/emacs/emacs_find_replace.html http://ergoemacs.org/emacs/find_replace_inter.html
Alt+x dired, then type a directory path, to list a directory.
Press ^
to go up a directory.
Now, your cursor should be on the directory you want to do the find/replace.
Select Only Some Files
If you want to find/replace only files ending in “.html”, or “.js”, or other selections of files, you need to mark files. When there are marked files, emacs will do find/replace only on those marked ones. When there are no marked files, emacs will do find/replace on the file/directory the cursor is on.
Mark Files/Directories
Press m to mark the file/directory under cursor. Press u to unmark the file/directory under cursor. Press U to unmark all marked.
Mark Files by Regex
Alt+x dired-mark-files-regexp 【\% m】 then type your regex pattern. For example, if you want to mark all files ending in “.html”, then type 【\% m】 then \verb|\.html$|.
hide details
M-x dired-hide-details-mode.
In dired, Alt+x dired-hide-details-mode. Key is (.
If you want it always on, add a hook. Like this:
(defun xah-dired-mode-setup () "to be run as hook for `dired-mode'." (dired-hide-details-mode 1)) (add-hook 'dired-mode-hook 'xah-dired-mode-setup)
How to delete or copy a directory?
Put this in your emacs init:
;; allow dired to delete or copy dir (setq dired-recursive-copies (quote always)) ; “always” means no asking (setq dired-recursive-deletes (quote top)) ; “top” means ask once
Then in dired, Alt+x dired-do-delete 【D】 to delete directory.
How to copy from one dired dir to the next dired dir shown in a split window?
Put this in your emacs init:
(setq dired-dwim-target t)
Eval the above or restart emacs. [see Evaluate Emacs Lisp Code]
Now, go to dired, then Alt+x split-window-below, then go to another dired dir. Now, when you press C to copy, the other dir in the split pane will be default destination. Same for dired-do-rename 【R】 and others.
How to make dired use the same buffer for viewing directory?
In dired, Alt+x dired-find-alternate-file 【a】 to open the file/directory without creating a new buffer.
If you want Enter and \verb|^| (parent dir) to use the same buffer, put the following in your emacs init file:
(require 'dired ) (define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file) ; was dired-advertised-find-file (define-key dired-mode-map (kbd "\verb|^|") (lambda () (interactive) (find-alternate-file ".."))) ; was dired-up-directory
How to hide some files?
Alt+x dired-do-kill-lines 【k】 to hide marked files.
File Related Tips
In a file, how to go to its directory and place cursor on the file name?
Put this in your init file:
(require 'dired-x)
In any file buffer, Alt+x dired-jump 【Ctrl+x Ctrl+j】 to jump to the directory of current buffer
dired-launch
Возможность открывать файлы предпочитаемой смотрелкой прямо из dired - файлового менеджера emacs-а. https://github.com/thomp/dired-launch
Способов достичь примерно этого, как обычно, более одного.
- Можно использовать в буфере dired
!
, чтоб запустить команду оболочки с указанным файлом в качестве аргумента. Но это каждый раз вводить эту команду, и не трогать emacs, пока не завершил просмотр. - Или
&
- то же самое, но выполнение "асинхронное", соответственно, emacs не дожидается результата, а вполне доступен, скажем, можно что-то из файла копировать, или заниматься посторонними делами. Но опять каждый раз вводить команду. - Или даже ещё хитрее, так, чтоб программа не закрылась при выходе из emacs:
C-u ! nohup command ? &
- openwith, который неимоверно меня раздражал, помнится. Потому что пытаешься уже из файлового менеджера емаксклиентом открыть, скажем, html, а заботливый openwith немедленно отправляет его в браузер. Трам-пам-пам.
- emacs-launch, с которым я незнакома, и наверное, ещё что-то мне неведомое.
- dired-launch - мой выбор на сейчас.
Ставится с гитхаба или через melpa. Позволяет выбрать запускалку для конкретных типов файлов и для вообще всего, если не нашлось ничего конкретного (xdg-open и mimeopen - как вариант).
По умолчанию J - для запуска "чем сам нашёл", K запрашивает, чем запускать (helm у меня при этом предлагает варианты), и потом интересуется, не запомнить ли выбор.
Ничего лишнего, просто и удобно. Главное, помнить, что это - есть. А то само о себе ничем не напоминает. )
image-dired
https://www.gnu.org/software/emacs/manual/html_node/emacs/Image_002dDired.html
С тегами пока не зашло. Да и вообще как-то с переменным успехом и временами почему-то не справляется с картинками. Хотя, кажется, с этим ситуация улучшилась просто по мере жизни и обновления на свежее.
Image-Dired is a facility for browsing image files. It provides viewing the images either as thumbnails or in full size, either inside Emacs or through an external viewer.
To enter Image-Dired, mark the image files you want to look at in the Dired buffer, using m as usual. Then type C-t d (image-dired-display-thumbs). This creates and switches to a buffer containing image-dired, corresponding to the marked files.
You can also enter Image-Dired directly by typing M-x image-dired. This prompts for a directory; specify one that has image files. This creates thumbnails for all the images in that directory, and displays them all in the thumbnail buffer. This takes a long time if the directory contains many image files, and it asks for confirmation if the number of image files exceeds image-dired-show-all-from-dir-max-files.
With point in the thumbnail buffer, you can type <RET> (image-dired-display-thumbnail-original-image) to display a sized version of it in another window. This sizes the image to fit the window. Use the arrow keys to move around in the buffer. For easy browsing, use <SPC> (image-dired-display-next-thumbnail-original) to advance and display the next image. Typing <DEL> (image-dired-display-previous-thumbnail-original) backs up to the previous thumbnail and displays that instead.
To view and the image in its original size, either provide a prefix argument (C-u) before pressing <RET>, or type C-<RET> (image-dired-thumbnail-display-external) to display the image in an external viewer. You must first configure image-dired-external-viewer.
You can delete images through Image-Dired also. Type d (image-dired-flag-thumb-original-file) to flag the image file for deletion in the Dired buffer. You can also delete the thumbnail image from the thumbnail buffer with C-d (image-dired-delete-char).
More advanced features include image tags, which are metadata used to categorize image files. The tags are stored in a plain text file configured by image-dired-db-file.
To tag image files, mark them in the dired buffer (you can also mark files in Dired from the thumbnail buffer by typing m) and type C-t t (image-dired-tag-files). This reads the tag name in the minibuffer. To mark files having a certain tag, type C-t f (image-dired-mark-tagged-files). After marking image files with a certain tag, you can use C-t d to view them.
You can also tag a file directly from the thumbnail buffer by typing t t and you can remove a tag by typing t r. There is also a special tag called “comment” for each file (it is not a tag in the exact same sense as the other tags, it is handled slightly differently). That is used to enter a comment or description about the image. You comment a file from the thumbnail buffer by typing c. You will be prompted for a comment. Type C-t c to add a comment from Dired (image-dired-dired-comment-files).
Умеет что-то там делать с картинками при помощи jpegtran. В дебиане оный jpegtran живет в пакетах libjpeg-progs и libjpeg-turbo-progs.
Минутка ностальгии
- Emacs Advanced dired Tips (File Management) http://xahlee.org/emacs/emacs_dired_tips.html - разумеется, ссылка неактуальна. Давно это было… :)