Open files with the system default application

I’ve mentioned crux before; it’s a package providing a set of general-purpose useful commands. One that I use all the time is crux-open-with, which opens the file currently being visited (or the file at the point in a dired buffer) using the system default application for that filetype. It works on Mac or Linux, by using the open or xdg-open commands respectively.

I bind the command to C-c o, using the following code (which also binds the previously mentioned crux-move-beginning-of-line)

(use-package crux
  :bind (("C-c o" . crux-open-with)
         ("C-a" . crux-move-beginning-of-line)))
Advertisement

2 comments

  1. If you use `counsel`, it has a default action for opening the file with an external application for `counsel-find-file` which is bound to `x` by default 🙂

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s