-
Notifications
You must be signed in to change notification settings - Fork 10
/
kakoune-shell-commands.el
27 lines (26 loc) · 1.09 KB
/
kakoune-shell-commands.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(defun kakoune-shell-pipe ()
"Run a shell command on each of the current regions separately and replace the current regions with its output."
(interactive)
(let ((command (read-string "Pipe: ")))
(mc/for-each-cursor-ordered
(shell-command-on-region (mc/cursor-beg cursor)
(mc/cursor-end cursor)
command
nil
1))))
(defun kakoune-shell-command ()
"Run a shell command on each of the current regions separately and insert its output before the respective regions."
(interactive)
(mc/save-excursion
(let ((command (read-string "Pipe: ")))
(mc/for-each-cursor-ordered
(mc/save-excursion
(goto-char (mc/cursor-beg cursor))
(insert
(with-output-to-string
(shell-command-on-region (mc/cursor-beg cursor)
(mc/cursor-end cursor)
command
standard-output))))))))
(provide 'kakoune-shell-commands)
;;; kakoune-shell-commands ends here