Jump to content

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).

Link to comment
Share on other sites

  • 10 months later...

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.

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...