Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Enter first match with shortcut key #164

Open
JakeElder opened this issue Apr 4, 2021 · 1 comment
Open

[Feature Request] Enter first match with shortcut key #164

JakeElder opened this issue Apr 4, 2021 · 1 comment
Labels
feature-request Feature Request

Comments

@JakeElder
Copy link

We can use the pet-select function to use the current line as a search string, IE

$ cat .zshrc
function pet-select() {
  BUFFER=$(pet search --query "$LBUFFER")
  CURSOR=$#BUFFER
  zle redisplay
}
zle -N pet-select
stty -ixon
bindkey '^s' pet-select

It would be useful to be able to select the first match automatically, bypassing the fuzzy finder. Something like

pet exec --first-match checkexp

This would invoke exec for the first match for the provided string, (IE for if you have a snippet with the description of "Check SSL Certificate Expiry Date"

Then we could make a function like this;

function pet-exec-first() {
  BUFFER=$(pet exec --first-match "$LBUFFER")
  CURSOR=$#BUFFER
  zle redisplay
}
zle -N pet-exec-first
stty -ixon
bindkey '^e' pet-exec-first

which would enable entering

$ checkexp

then pressing <ctrl-e> to have it expanded to the Check SSL Certificate command

Combine this with #163 to have a much lighter workflow, IE, I'd like to be able to enter

$ commitfeat

then press <ctrl-e> to expand to

git commit -am "feat(ui): <cursor is here>"

and be able to type my commit message, without going through the interactive fuzzy find step and entering parameters via the pet form, while still retaining that great functionality when needed for more obscure snippets that have more than one parameter

@RamiAwar
Copy link
Collaborator

RamiAwar commented Feb 17, 2024

This is very interesting @JakeElder , such a good idea!

Wonder if we can make it work for multiple parameters too..

I've seen a lot of people want to bypass the pet parameter filler for speed purposes as well as shell autocomplete.
Maybe that's the problem and we can make the pet parameter filler faster and supporting autocomplete somehow? Would be hard though.

I think it's nice to be able to support your functionality optionally though.

@RamiAwar RamiAwar added the feature-request Feature Request label Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Feature Request
Projects
None yet
Development

No branches or pull requests

2 participants