Is it possible to add text, as if the user typed something, to the current bash user input prompt (not the information display prompt, input after the $
or #
).
For example, (stupid example)
Say I want a command that adds 'sudo' to the next prompt after pressing enter
user@computer ~$ runAsSudo # ENTER PRESSED
user@computer ~$ sudo █ # █ is the cursor
My real application for this is having a command that undoes something, for example a copy, but instead of running it or asking for y/n, it simply adds it to the input prompt where the user can do whatever.
user@computer ~$ cp myFile /some/long/path/ # ENTER PRESSED
user@computer ~$ undo # ENTER PRESSED
user@computer ~$ cp /some/long/path/ myfile █ # █ is the cursor