Hacker News new | ask | show | jobs
by gvalkov 3881 days ago
I hope more command-line interfaces adopt a similar pattern. I pet peeve of mine is searching for a package (irrelevant of the package manager) and then installing it. In terms of interaction, it goes on something like this:

   $ ${tool} search ${pattern}
   res1
   res2
   res3
   # I'm interested in the first and last package names.
   $ ${tool} install <grab mouse> <double-click res1> <shift-insert> <double-click res3> <shift-insert>
   # On a side-note, this can also be done with tmux copy-mode by appending the
   # results to a buffer, but I personally find that using the mouse is faster
   # in this case.
Enumerating the results of the search and doing a '${tool} install %1 %3' would be a huge improvement. I once offered to add [1] such functionality to freebsd binary package manager, but nothing came out of it (perhaps for good reasons).

[1]: https://github.com/freebsd/pkg/issues/1041

1 comments

With zsh:

$ $(tool) search $(pattern)

res1

res2

res3

# press arrow up, home, r= (`, end, `)

$ r = ( `$(tool) search $(pattern)`)

$ tool install r[1] r[3]

Or use a fuzzy matcher...peco and fzf (the go version) are my favorites, since they install with no dependencies on a runtime, but there are python/ruby options (fpp, selecta, percol) as well.