fzf icon indicating copy to clipboard operation
fzf copied to clipboard

Last token is not used for Ctrl+T on fish shell

Open pvonmoradi opened this issue 2 years ago • 6 comments

According to https://github.com/junegunn/fzf#fish-shell, on fish shell, Ctrl+T should use the last token as the base of recursive search but it does not behave like that. It uses CWD as the root of search.
So ls /var/ does not list files under /var/.

https://asciinema.org/a/dhSwXLxkpUc2VaoKuag3begsH

  • OS

    • [x] Linux Xubuntu 18.04
  • Shell

    • [x] fish fish, version 3.3.1
  • FZF

    • [x] fzf 0.27.2 (e086f0b)

pvonmoradi avatar Jul 19 '21 12:07 pvonmoradi

Thanks for the report. I don't use fish and I'm not familiar with its syntax, so please open a pull request if you can fix the problem.

junegunn avatar Jul 20 '21 05:07 junegunn

@junegunn Exactly happens with bash, doesn’t it?

When I am in ~/build and I write ls ~/Dok and then I press Ctrl-T I would expect fzf will start to search sub-tree of ~/Dokumenty (there is no other completion of Dok in my $HOME directory). However, it does the worst thing. It starts from ~/build and then adds the resulting filepath (inclduing the leading ~/Dok) as the result, which makes it almost useless.

mcepl avatar Feb 02 '22 01:02 mcepl

@mcepl Yes, as documented in https://github.com/junegunn/fzf#fish-shell

CTRL-T key binding of fish, unlike those of bash and zsh, will use the last token on the command-line as the root directory for the recursive search.

But bash and zsh have fuzzy completion.

  • https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh

junegunn avatar Feb 02 '22 13:02 junegunn

@mcepl Yes, as documented in https://github.com/junegunn/fzf#fish-shell

CTRL-T key binding of fish, unlike those of bash and zsh, will use the last token on the command-line as the root directory for the recursive search.

OK, so perhaps this is just RFE for the option that bash (and perhaps zsh, but I don’t care for that) would behave similarly? I work for SUSE as a main Python maintainer, so my ~/build (with all expanded packages in couple of large OBS projects) has 9500+ subdirectories and 90,000+ files. Of course, I use the fuzzy completion all the time (and thank you for that), but Ctrl-T with bash is for me essentially useless, but it could be crazily useful if I could with some gentle nudge start it in the right direction.

mcepl avatar Feb 02 '22 16:02 mcepl

I actually don't know how to accomplish that in bash or zsh.

Anyway, I think it's good that CTRL-T binding is provided as a simpler, easier-to-understand alternative to fuzzy completion.

See my previous comment on that matter: https://github.com/junegunn/fzf/issues/2450#issuecomment-829856724

junegunn avatar Feb 03 '22 00:02 junegunn

I actually don't know how to accomplish that in bash or zsh.

What’s the problem? You cannot read an unfinished line in a bash script?

mcepl avatar Feb 03 '22 09:02 mcepl