Jump to content
jafergus

Better query history - partial search

Recommended Posts

I have zsh configured with 1000's of lines of stored command history and the capability for partial history searching. That way if I begin a command I've previously used and press Up I can go through my history in reverse order of just commands with that prefix. So if I've previously typed `cd /etc/` then typed some other commands not beginning with `cd` and then later type `cd ` and key up then it jumps to the line in history beginning with `cd` which is `cd /etc/`.

 

In practice this is very useful when you know you fairly recently used a command with long params and you want to jump to it to use the same params. It's also very useful with commands that have a limited number of possible params because once you have an established history you can just type the command and scroll through all the possible params (note, history is most useful here if it is reduced to unique commands, not keying through 20 instances of using the same one or two params to find the time you used a third variation).

 

For an example use case, I'm a developer, our company has 10-20 repos/projects we're working on. There are a range of workflows and custom urls we might want to setup that might take one of these repos as a param (open GH page for the repo, open CI for the repo etc). Rather than create a separate workflow keyword or custom url for, say, 8 commands times 20 projects, 160 keywords, or laboriously typing the same repo param in full each time, this feature would allow me to just setup the 8 commands and start using them and (once I've built up the history) then I can usually complete a command by typing its name and keying up a few times. Because commands are stored in historical order keying up will also usually hit the most commonly used projects first (or you could explicitly design it to show partial history matches in order of frequency of use in the history).

Share this post


Link to post
Share on other sites

Yep, there are complex workflows and argument heavy workflows that I just don't use because the only history search command I know is "up".

 

For example, there's this "What's binding the port" workflow, that I sometimes really need (because something is taking up a port) but normally I don't use every day, the syntax is very hard to remember. In the terminal, I have fzf so I never get frustrated typing a long command, I know I'll never have to type it again if I remember a part of it.

Share this post


Link to post
Share on other sites

While Alfred is a keyboard-driven interface, it isn't meant to be a command line. It natively supports one keyword and one optional argument. Workflows that use complex input syntax on top of that are generally misusing or abusing the interface.

 

While I would certainly like to see a persistent, searchable history in Alfred, the lack thereof isn't what makes the "What's binding the port" workflow and similar hard to use. The problem is workflow authors making no attempt to provide a suitable UX.

 

The "What's binding the port" workflow, for example, should just run lsof -Pi (or similar) once, parse the output, and then present the results to the user for filtering. There's not much reason to allow you to filter the output from lsof by protocol/hostname/etc. via command-line options because Alfred gives you a much better UI for filtering.

Share this post


Link to post
Share on other sites
On 5/1/2019 at 1:57 AM, jafergus said:

this feature would allow me to just setup the 8 commands and start using them and (once I've built up the history) then I can usually complete a command by typing its name and keying up a few times.

 

This is easy to do in Alfred. One List Filter to choose the command connected to another to choose the project. Or combine both into a single Script Filter.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...