Skip to content
This repository has been archived by the owner. It is now read-only.

Conversation

@xPMo
Copy link
Contributor

@xPMo xPMo commented Mar 29, 2023

Additionally, exit out without querying or saving history if query was empty. ChatGPT has typically responded with something like "please submit a query".

Exit out without querying or saving history if query was empty
@not-poma
Copy link
Owner

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.

@xPMo
Copy link
Contributor Author

xPMo commented Mar 30, 2023

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:

  • If read-from-minibuffer exits nonzero, which happens when the user hits ctrl-c, return
  • If query and buffer are empty, return
  • If query is empty, ask GPT to "fix the command $buffer"
  • If buffer is empty pass query as is.
  • If neither is empty, ask GPT to "fix the command $buffer to comply with query $buffer

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants