junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
64.65k stars 2.38k forks source link

FZF_CTRL_T_COMMAND does not work with absolute paths #943

Closed ipwnponies closed 7 years ago

ipwnponies commented 7 years ago

The bindings for in fish support taking a starting directory for search path. This does not work for absolute paths:

>> /Library/<C-T>
>
/ 163216/165601
  ibrary/Application Support
  ibrary/Application Support/App Store
  ibrary/Application Support/App Store/adoption.plist
> ibrary/Application Support/Apple
  ibrary/Application Support/Apple/Automator

The default FZF_CTRL_T_COMMAND always strips the first two characters on this line at the cut command. This only works for relative paths since they are prefixed with ./.

This always breaks for absolute paths or paths that are shell expanded to absolute paths ($HOME, ~, etc.):

>> $HOME<C-T>
>
\ 492016/496833
> sers/foo/Applications
  sers/foo/Applications/Amethyst.app
  sers/foo/Applications/Amethyst.app/Contents
  sers/foo/Applications/Amethyst.app/Contents/_CodeSignature
  sers/foo/Applications/Amethyst.app/Contents/_CodeSignature/CodeResources
  sers/foo/Applications/Amethyst.app/Contents/Frameworks
  sers/foo/Applications/Amethyst.app/Contents/Frameworks/Cartography.framework
ipwnponies commented 7 years ago

I'm not sure why it's needed to strip the ./ for relative paths at all. It seems to be aesthetics as completions with leading ./ will still work correctly. If it's not required, the fix is simple as removing the extraneous cut -b3- command.

junegunn commented 7 years ago

Thanks, it should be fixed now.