Skip to content
Improved "open with" suggestions for dired mode in Emacs
Emacs Lisp
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This library links a set of shell commands to file or directory names. These commands can then be used in dired mode using dired-do-shell-command (by pressing “!”). Since this library modifies the behavior of dired-guess-shell-alist-user, the command syntax will follow that variable’s syntax (see the documentation of dired-do-shell-command for more).


  • Provides a widget.el interface to add, edit, and sort shell commands.
  • Gets rid of the “A command is running - kill it? Yes or No?” message.
  • If command string contains “{run:out}”, then keep output in a specially named buffer.
  • If command string contains “{run:shell}”, then run command using the function specified in runner-shell-function.
  • When runner-run-in-background is active, hide all output buffers except when the command string contains “{run:out}”.
  • For other options, see M-x customize-group runner.


Using Melpa:

M-x package-install RET runner RET

Then add this into your init file:

(require 'runner)

The functions dired-guess-default (from dired-x.el) and dired-run-shell-command (from dired-aux.el) will be redefined.


While in dired mode, position point on any file or directory you wish to add a shell command to, then do:

M-x runner-add-file (for file or directory names)
M-x runner-add-extension (for file extension)

A new buffer will be created allowing you to specify what commands to run.

A file name or extension can be linked to multiple set of commands. You can view and edit which pattern is being applied to a file by positioning point on a file and running,

M-x runner-edit-file-at-point

You can also add, edit, or delete any specific pattern by doing:

M-x runner-add-empty
M-x runner-edit
M-x runner-delete

The command database will be saved to the file runner-init-file (default is “~/.emacs.d/runner-conf.el”). You may choose a different location by doing:

M-x customize-variable runner-init-file

Related libraries

  • Unify-opening - extend dired and runner open file mechanism to other modes.


For shell commands that rely on the base name of a file, the following bash script (saved as “run-f”) can be useful:

# Return the base file name sans extension. If more than
# one file is passed, just return the first one.
for file in "$@"
    echo "$FILESANSEXT"

For example, in runner this command creates a text file from a scanned PDF using the same filename:

{run:out} pdf2djvu -o "$(run-f ? ).djvu" ? && ocrodjvu -o "$(run-f ? )_ocr.djvu" "$(run-f ? ).djvu" && djvutxt "$(run-f ? )_ocr.djvu" "$(run-f ? ).txt" &
Something went wrong with that request. Please try again.