Closed Juliocj7 closed 1 year ago
Maybe something like the following.
HISTFILE=$TMPDIR/prompt_history
read -e prompt
history -s -- "$prompt" ; history -a
The hist file will be re sourced with previous buffers when the script is run again. Avoid running a subshell for this.
@Juliocj7 Thank you very much for submitting another PR! I think you were too fast to close the PR, I didn't have time to properly review it. I have two concerns about this solution, that I didn't have time to test and research. If you can answer these questions it would be great: 1) It should be a function not a subshell. It would be simpler and easier to maintain. 2) It is not completely clear to me what happens when setting the histfile to a file in a temp dir, how does that affect the bash history of other terminal sessions? Do the commands typed in chatgpt get stored in bash_history?
I like the current way of working where the chatgpt history is isolated in a separate file and we can manipulate as we want without touching the bash_history.
Second try:
Avoiding using rlwrap this adds interactivity and also a live record of the questions asked.