I need to send keystrokes virtually to a terminal program (like vi or emacs).
I want to do something like this:
echo -e 'iHello, world!\e' | vi
and then have a vi session open with this buffer:
Hello, world!
~
~
~
~
~
But that does not work as vi does not read keystrokes through stdin.
I get this error:
ex/vi: Vi's standard input and output must be a terminal
How can I send some text string to a terminal program as if the string was typed directly on a keyboard?
expectfor this, as the most general case, but that's often a pain. It may be preferable to write a more specific script using shell.echo 'Hello, world!' | vipeseems relevant. joeyh.name/code/moreutils orapt install moreutils