fzy icon indicating copy to clipboard operation
fzy copied to clipboard

Keep history of searches

Open max-baz opened this issue 7 years ago • 2 comments
trafficstars

FZF has a very interesting feature, it remembers all your searches and allows you to scroll them to repeat past search.

For example, suppose you use zsh-fzy (you really should merge #58, btw 😉) and you want to select two files that both match your filter "myverylongfilter".

Ideal way of course is to use multiple selection (#93) and just select both files at once, but you could have also selected a file, then fire up fzy again and press a shortkey to bring up the last search instead of typing "myverylongfilter" again.

The relevance of this request really depends on your decision about multiple selection (#93), if it gets implemented the need for history will become much smaller for me.

max-baz avatar Oct 22 '18 13:10 max-baz

I don't know @maximbaz whether it's related to your question or not, but I have a request on a similar concept: I have a project that is located at /home/stefanos/code/ and in it I have multiple folders with subfolders that contain files.

If I open a file which is located at, let's say /home/stefanos/code/folder-a/foo.php, I cannot go back to /home/stefanos/code and look for another file or folder.

I guess my issue is more related to Vim's script than fzy's.

stefanos82 avatar Oct 25 '18 18:10 stefanos82

I have solve it by doing something simple.

I have changed the original Vim sample as follows:

function! FzyCommand(choice_command, vim_command)
  try
    let output = system(a:choice_command . " | fzy ")
  catch /Vim:Interrupt/
    " Swallow errors from ^C, allow redraw! below
  endtry
  redraw!
  if v:shell_error == 0 && !empty(output)
    exec a:vim_command . ' ' . output
  endif
endfunction

let findcwd = "find " . expand('%:p:h') . " -type f"
nnoremap <leader>e :call FzyCommand(findcwd, ":e")<cr>
nnoremap <leader>v :call FzyCommand(findcwd, ":vs")<cr>
nnoremap <leader>s :call FzyCommand(findcwd, ":sp")<cr>

This works exactly as I wanted it.

stefanos82 avatar Oct 25 '18 20:10 stefanos82