Fzf: Is there a way to see the end of the filename/path instead of the beginning?

Created on 23 Mar 2019  ·  6Comments  ·  Source: junegunn/fzf

  • Category

    • [x] fzf binary

    • [ ] fzf-tmux script

    • [ ] Key bindings

    • [x] Completion

    • [ ] Vim

    • [ ] Neovim

    • [ ] Etc.

  • OS

    • [x] Linux

    • [ ] Mac OS X

    • [ ] Windows

    • [ ] Windows Subsystem for Linux

    • [ ] Etc.

  • Shell

    • [ ] bash

    • [x] zsh

    • [ ] fish

I work with very long file paths. I want to show the ending of the path (near where the files are). Is this possible?

question

Most helpful comment

It is possible.

echo '/very/long/file/path.sh' | fzf --delimiter / --with-nth -1

All 6 comments

It is possible.

echo '/very/long/file/path.sh' | fzf --delimiter / --with-nth -1

Not exactly what you want, but another thing you can do is to enable toggleable (or always-on) preview window for showing the full path.

fzf --preview 'echo {}' --preview-window down:2

fzf --bind ?:toggle-preview --preview 'echo {}' --preview-window hidden:down:1

It seems that the preview window approach is also truncated at the end. Is there any other solution for maximizing the amount of path that is shown starting from the end?

@junegunn

Not exactly what you want, but another thing you can do is to enable toggleable (or always-on) preview window for showing the full path.

fzf --preview 'echo {}' --preview-window down:2

fzf --bind ?:toggle-preview --preview 'echo {}' --preview-window hidden:down:1

Can we have a way to just prioritize showing the end? I do not want the --with-nth because I need to search through the higher dirs sometimes, and the preview window solution doesn't let me see everything at a glance.

Check out --keep-right option.

Just another option if all you care about is the last field Two solutions come to mind

fzf   --preview=“basename <<<{}”
fzf --preview=“awk -F/ 'NF>=3{ print $(NF-2), $(NF-1), $NF}' <<<{}” #last 3 fields

Wrap in a while loop-
Where output grater than fzf_default_columns do truncate

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leonklingele picture leonklingele  ·  3Comments

sassanh picture sassanh  ·  3Comments

fenuks picture fenuks  ·  3Comments

erusev picture erusev  ·  3Comments

lbeier picture lbeier  ·  3Comments