-
Notifications
You must be signed in to change notification settings - Fork 81
Description
I've realized that for my two main coding use cases (git add and opening files in Vim), I almost always need to select more than one thing. For instance, I'll usually change prod code together with test code, and then want to add both to git:
> CM.java (2/78 choices)
src/main/java/com/github/rschmitt/collider/ClojureMap.java
src/test/java/com/github/rschmitt/collider/ClojureMapTest.java
This quickly gets annoying, since I'll end up typing the exact same query twice for no good reason. If I want to git add (or open), say, five files (which is hardly uncommon), this gets tedious enough that I'll switch to git add -i, git add -p, or copy-and-paste using the mouse, because invoking hs repeatedly is just too cumbersome.
I took the time to whip up a prototype of multi-select functionality in Heatseeker, and so far it really seems like it has legs. It looks like this:

Thanks to Rust stabilization, you can now install Heatseeker using Homebrew to play with this feature:
brew install https://raw.githubusercontent.com/rschmitt/heatseeker/master/heatseeker.rb
The controls are:
- Control-T will toggle the currently highlighted choice and move the cursor down.
- Enter will select everything that has been selected, as well as the currently highlighted choice.
- Control-G will select everything that has been selected, but not the current choice, unless it has been selected with Control-T.
To support multiselect, the SelectaCommand script can be modified as follows (note that I'm using this with :tabe rather than :e):
function! SelectaCommand(choice_command, selecta_args, vim_command)
try
silent let selections = system(a:choice_command . " | hs " . a:selecta_args)
catch /Vim:Interrupt/
redraw!
return
endtry
redraw!
for selection in split(selections)
exec a:vim_command . " " . selection
endfor
endfunctionAnd the zshrc function insert-selecta-path-in-command-line only needs a one-line change:
selected_path=$(find * -type f | hs | paste -sd' ' -) || return