Open xPMo opened 1 year ago
I think merging history saving makes sense when the script can actually fetch the past queries on up/down keys.
Empty response change is a good idea, can be merged immediately if you submit it in a separate PR.
I think merging history saving makes sense when the script can actually fetch the past queries on up/down keys.
Unless I'm misunderstanding you, that's exactly what I've implemented here. read-from-minibuffer
uses zle recursive-edit
under the hood, which can go up and down through history. By first fc -ap
, we load a new history file such as ~/.zsh_history.lazyshell-complete
which read-from-minibuffer
can scroll through, and ask zsh to unload it when the function exits. If the user entered a query, print -sr
adds it to the current history file.
Empty response change
I've actually played around with a few things in my fork, and realized there is value in allowing an empty buffer to trigger a request. Here's what I put together over there:
read-from-minibuffer
exits nonzero, which happens when the user hits ctrl-c, return$buffer
"$buffer
to comply with query $buffer
Additionally, exit out without querying or saving history if query was empty. ChatGPT has typically responded with something like "please submit a query".