In vim, it's pretty common to run commands like
It's pretty simple and the syntax is really easy to remember, ":" for command mode, "!" to run something, and in the command "%" will be replaced by your filename.
I haven't found anything similar to "%" for emacs, so let's write some elisp to fix it.
(defun shell-execute () (interactive) (let ((file-buffer (or (buffer-file-name) "")) (command (read-shell-command "Shell command: " nil nil nil))) (shell-command (replace-regexp-in-string "%" file-buffer command)))) (global-set-key (kbd "M-!") 'shell-execute)