Pete's Linux Advent Calendar 2008
The 14th day
Interaction of Emacs with the Shell
Using Emacs? Here are two Emacs Lisp functions that you can put
in your ~/.emacs file:
(defun shell-command-in-buffer (start end command)
"prompts for command to execute and
replaces output of shell-command-on-region with current buffer."
(interactive "r\nsKommando: ")
(shell-command-on-region start end command nil t))
(global-set-key "\M-|" 'shell-command-in-buffer)
(defun insert-shell-command-output (command)
"prompts for a shell command to execute and puts output after point."
(interactive "sKommando: ")
(shell-command command t))
(global-set-key "\C-x!" 'insert-shell-command-output)
With these you can modify your buffer directly with any shell command.