DWIM Shell Commands

Álvaro Ramírez is relentless in chasing down ways to eliminate friction from his workflow. One day it occurred to him that invoking shell commands was an area with plenty of opportunities for workflow optimization. A particular problem was that many of the commands he used frequently, such as ffmpeg and convert have a lot of arguments and flags that are hard to remember.

Ramírez’s solution was a write tiny bits of Elisp that would invoke the desired commands without having to remember all the details. To make this work, he first defined a general template framework that allowed specifying what the command should look like with parameters for the file path and parts of the file name.

Because it’s DWIM, the framework does the right thing depending on the context. If you’re in a Dired buffer, the command will operate on all the marked files. If you’re in a file buffer, the command will operate on the associated file. Similarly, how the output of the command is shown depends on the context in which it was invoked. Take a look at Ramírez’s post for the details.

You can check out the framework code, dwim-shell-command.el, to see how things work but the examples in the post are really all you need. Once the framework is in place, adding new DWIM commands is simple. The post has several examples.

If you’re the type of Emacs user who’s always looking for ways to sand down the rough spots in your workflow, take a look at Ramírez’s post. As Ramírez says, if your needs are different, it’s easy to adjust things to suit your requirements.

This entry was posted in General and tagged . Bookmark the permalink.