After a command terminates in shell-mode
, I want to execute an additional command conditional on stdout
. How can this be automated?
Asked
Active
Viewed 81 times
1

Matthew Piziak
- 6,038
- 3
- 31
- 79
-
1Could you give a minimal example of output and command? – wasamasa Dec 11 '14 at 19:17
1 Answers
1
Add a hook to comint-output-filter-functions
. In the example below, ls
is sent to the shell if the output from a command matches "foo"
.
(defun my-hook (str)
(when (string-match "foo" str)
(insert "ls")
(comint-send-input)))
(add-hook 'shell-mode-hook
(lambda ()
(make-local-variable 'comint-output-filter-functions)
(add-hook 'comint-output-filter-functions #'my-hook)))

Constantine
- 9,122
- 1
- 35
- 50