I have a program which can be invoked with an ncurses TUI (no arguments), or with arguments.
The effect of myprog foo
is the same as running myprog
and choosing foo
from the menu.
When a user runs myprog
and chooses foo
, I would like to replace the last myprog
entry in their bash history with myprog foo
, so that they can repeat the action without having to go back into the TUI and choose foo
again.
Note: I am not asking about modifying the .bash_history file. I need to find a mechanism for replacing the last (in-memory) history command in the parent bash process.
How can I replace the last entry in the calling bash process’ history?