Artificial intelligent assistant

How can I make readline add pre-"typed" text on terminal startup? By pre-"typed", I mean the interactive console has code text waiting for the user to (edit and) run by simply pressing enter. It looks like something readline should support, but a confirmation that it doesn't is good enough. At least I will know that installing an additional automation tool (like expect) is the only way.

Not sure if this helps, and is not per readline, but if python is an alternative (or some similar) one approach could be in the direction of:


#!/usr/bin/env python
""" Inject command to own command line """

import sys, fcntl, termios

def main():
""" x """
tty = sys.stdin
old_attr = termios.tcgetattr(tty)
new_attr = termios.tcgetattr(tty)
# No echo please
new_attr[3] &= ~termios.ECHO
termios.tcsetattr(tty, termios.TCSANOW, new_attr)

cmd = ' '.join(sys.argv[1:])
for char in cmd:
fcntl.ioctl(tty, termios.TIOCSTI, char)

termios.tcsetattr(tty, termios.TCSANOW, old_attr)

if __name__ == '__main__':
main()


As in:


script_name command to inject

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 1049f9c99ea1db1ad15cb16c05f866b9