garybernhardt / selecta

A fuzzy text selector for files and anything else you need to select. Use it from vim, from the command line, or anywhere you can run a shell command.
MIT License
1.34k stars 81 forks source link

Use input directly #64

Closed rosshadden closed 9 years ago

rosshadden commented 9 years ago

I think it would be quite useful if selecta had a bind that use what the user currently has entered, like Control+Enter or Shift+Enter or something.

This would mean given a list with abcd present, if the user types abc and hit said bind, abc would be passed through as the result even though abcd was highlighted.

This would let users select things that are not in the list if applicable to their situation.

garybernhardt commented 9 years ago

Can you explain what use case prompted this?

rosshadden commented 9 years ago

Hitting Shift+Enter to submit the current input is a feature that dmenu and its many clones support, and I have gotten used to it. Consider this example, straight from your README:

git branch | cut -c 3- | selecta | xargs git checkout

Naturally the point is to checkout a branch. With the feature I outlined above, however, you could input "1f8ae1a4aaShift+Enter", and git would check out whatever was entered (which is your latest commit at the time of this writing). Or you could enter a tag, or a remote branch.

Instead of piping to git-checkout directly, you could even pipe it to a simple script that runs git checkout $input if the branch/tag/commit exists, and otherwise git checkout -b $input. In fact this, to answer your question directly, was the use case that prompted this.

Let me know what you think.

bentomas commented 9 years ago

I'd much rather Shift+Enter selected the current selection and caused ZSH to run the current line. I took a stab at programming this up, but couldn't figure it out. Either way, I think the suggested functionality in this issue should be configurable, as I haven't given up on getting Shift+Enter to work how I want it to at some point.

rosshadden commented 9 years ago

I think Control+Enter is good too. It doesn't really matter what the bind ends up being.

Thoughts?

untitaker commented 9 years ago

I am not sure either Ctrl+Enter or Shift+Enter is even reliably detectable?

garybernhardt commented 9 years ago

They're not; neither of those keystrokes is detectable on my machine. I thought I'd replied to this thread about that, but apparently not!

This feature would break a contract that Selecta follows implicitly: every keystroke that it understands will be very standard. Enter selects things; ESC and ^C quit; ^P and ^N move through the list; etc. There's no standard key for the behavior we're talking about here, so I'm going to veto it for now. If the standard-keystroke rule ever goes away (which would require a very compelling feature addition), we can revisit this.