Using elisp (not interactive key-chords), how can I run a command in emacs terminal emulator; and how can I send key-presses to that buffer?
Starting term seems to require (term "/bin/bash"), which has no scope for running a command. I assume that might be because term is intended as an interactive tool…
Also I want to send specific keys to the running app. Can this be done. I thought (insert ‘x) might work, but it doesn’t have a buffer parameter, nor does it allow for M- C- S- s-
You can send input directly to the terminal with
term-send-raw-string. Example:This will simulate the effect of typing
ls -lRET into the terminal buffer.While
termisn’t very flexible about argument parsing, it’s usually sufficient to start up a shell and feed it commands withterm-send-raw-stringto load up the target program. Here’s a little piece of elisp that scripts some commands to an interactive program: