Skip to content

Instantly share code, notes, and snippets.

@russellmcc
Last active August 23, 2022 03:16
Show Gist options
  • Save russellmcc/58ed75dbb7924734f20773cab1525a34 to your computer and use it in GitHub Desktop.
Save russellmcc/58ed75dbb7924734f20773cab1525a34 to your computer and use it in GitHub Desktop.

On Apple’s Terminal.app, dragging a file into the terminal inserts the path to the file as text. This feels ergonomic to me; here’s a quick way to set up vterm to do the same thing:

(defun russruss/insert-local-url-as-path-vterm
    (url &optional action)
  (vterm-send-string
   (car
    (url-path-and-query
     (url-generic-parse-url url)))))

(add-hook 'vterm-mode-hook
  (lambda ()
    (setq-local dnd-protocol-alist
                `(("^file:" . russruss/insert-local-url-as-path-vterm)
                  ,dnd-protocol-alist))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment