2

I've been struggling to find a simple answer to this and it seems like it is not trivial to customise the default integration of fzf/zsh (would like to understand if I'm wrong here).

I am looking for the following behaviours:

  1. The thing I'm searching for is automatically being filled in, so the first time I press enter, the command runs (by default it requires two taps, you press enter to select the command, then you run it)
  2. I don't really need a massive list of possible entries that much, if I could remove this, that would be great
  3. If I do have a list, I would like to be reversed, so the top entry is the one that matches the closest (by default it's the bottom entry).

Effectively I would just like the default backward search but supporting fuzzy matching, I'd prefer no styling/functionality differences aside from that.

Is this configuration possible out of the box with fzf?

rbhalla
  • 121
  • 1
  • I believe I have a possible solution but I'm not sure if it is what you want. What I understood is that you want an interactive history, like [this](https://i.stack.imgur.com/vLE6K.png) perhaps? but the condition here is that when you press some item in your interactive history the command should be executed automatically (without pressing enter again) or am I wrong at this point? – Edgar Magallon Oct 20 '22 at 23:50
  • About point 2: *I don't really need a massive list of possible entries that much*, do you want to be able to specific a range of history entries? For example, the last 10 entries. – Edgar Magallon Oct 20 '22 at 23:55
  • And about your last point I'm not sure what you want. When you type `history` this one shows all commands/entries you have typed from older to newer (the last line it's your more recent command). So do you want to display from newer to older (the last line would be your first command)? – Edgar Magallon Oct 21 '22 at 00:00
  • Hey @EdgarMagallon! [This](https://i.imgur.com/Cn237ZG.png) is what I mean for point 1. Note how I've searched history, but the autocomplete is being entered into my current prompt, so when I press enter, that's what executes. On point 2, ideally I see no previous entries at all, just the last one. On point 3, it seems like the default fzf setup has the search results below the prompt where the bottom result is the most accurate one. If I *had* to see previous entries, it'd be nice if the most accurate entry was the one closest to my prompt – rbhalla Oct 21 '22 at 19:16
  • 1
    I've searched about `bck-i-search` in zsh but I was not able to know how could I edit it to use `fzf`. I used the following command: `bindkey -L | grep back` to detect the function which is executed when you press **Ctrl+r** and it seems is this: `history-incremental-search-backward` but I was not able to found where is that function to can edit it. – Edgar Magallon Oct 21 '22 at 22:07
  • This is the [install file](https://github.com/junegunn/fzf/blob/master/install) and this is the [zsh key bindings](https://github.com/junegunn/fzf/blob/master/shell/key-bindings.zsh) but I'm not sure I understand what's happening well enough to modify – rbhalla Oct 21 '22 at 22:32
  • Maybe it's not possible (or it's a little tricky). I think you should post this in that GitHub (maybe as a question or as a feature). Btw, the image I provided about using an interactive history with `fzf` it's a nice feature and you are able to search in the same way you use `bck-i-search` although you have to press double enter to run the command it can be modified to run with a simple enter. – Edgar Magallon Oct 22 '22 at 02:10

0 Answers0