Now it's time to speak about external programs, which could be called from inside Dired.
By default, the Emacs tries to open any file inside itself, if user presses RET on the file in the Dired buffer. But, it may be convenient to open some files with external programs, for example open videos with MPlayer or open an image with nSxiv. And the variable dired-open-extensions could help with that!
It is just a list of conses, where the car is the file extension and the cdr is the program (from $PATH in my case) which should open all the files with such extension:
( setopt dired-open-extensions ' ( ( "png" . "sxiv" ) ( "PNG" . "sxiv" ) ( "jpeg" . "sxiv" ) ( "jpg" . "sxiv" ) ( "JPEG" . "sxiv" ) ( "JPG" . "sxiv" ) ( "gif" . "sxiv" ) ( "GIF" . "sxiv" ) ( "webp" . "sxiv" ) ( "WEBP" . "sxiv" ) ( "avi" . "mplayer" ) ( "m4a" . "mplayer" ) ( "mkv" . "mplayer" ) ( "mp3" . "mplayer" ) ( "flac" . "mplayer" ) ( "mp4" . "mplayer" ) ( "webm" . "mplayer" ) ( "eps" . "gv" ) ) )
I think, this part of configuration is self-explanatory — it instructs Dired to open all images with sxiv command, and all videos with mplayer command.
Let's look to another way to launch specific programs for specific files in the Dired. I'm speaking about dired-guess-shell-alist-user variable and the ! or & hotkeys in the Dired buffer.
First thing, you (as a reader) should know, The ! hotkey in the Dired buffer will run entered command synchronously — so Emacs will lock itself, while the command is running. Sometimes, when the command (like gm convert ) will exit very fast, it is OK and I could wait some small time while my files are transforming. But, some commands take a lot of time, so there the & is to the rescue. It will run the entered command asynchronously, so the Emacs will not be locked while the command is running. It is useful for e.g. converting some video files from WEBM to MP4, etc.
Of course, the entered command will be applied to the file under the cursor or to the marked files in the Dired buffer.
Second thing: after your press one of the before-mentioned keybindings, then the Dired will show you the prompt in the minibuffer, like this:
And there are two important keybindings:
... continue reading