I'm trying to replicate the behavior of the history builtin: specifically when you do !<line # of command> and it's just replaced with the command at line #.
Let's say that I have a file with the following contents:
cd ~/some/path
I would like to be able to take the contents of that file and have that pushed into the current terminal input line as such:
$ ./put_to_input file
$ cd ~/some/path # pulled from the file, not manually typed
Not sure if this is possible. Help would be appreciated!
Clarification:
I want to put the lines of the file into the terminal input, as if the person had typed it themselves. Similar to if you use the
!nshell history substitution. https://opensource.com/article/18/6/history-command