Created
April 21, 2021 17:10
-
-
Save kidd/d7dff019010e5b0eb5ae0aa9ce6c7580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun shell-execute () | |
(interactive) | |
(let ((file-buffer (buffer-file-name)) | |
(command (read-shell-command "Shell command: " nil nil | |
(let ((filename | |
(cond | |
(buffer-file-name) | |
((eq major-mode 'dired-mode) | |
(dired-get-filename nil t))))) | |
(and filename (file-relative-name filename)))))) | |
(shell-command (replace-regexp-in-string "%" file-buffer command)))) | |
(global-set-key (kbd "M-!") 'shell-execute) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment