Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!
MIT License
3.28k stars 94 forks source link

[Q] Is there way to set the height of the preview window? #452

Closed mxcury closed 2 months ago

mxcury commented 2 months ago

Describe your question I've added the following zstyle line to my .zshrc to view my file contents:

zstyle ':fzf-tab:complete:bat:*' fzf-preview '[[ -d "$realpath" ]] && ls --color "$realpath" || bat --style=numbers --color=always "$realpath"'

I'm trying to increase the height of the preview window to be 10 lines in height. Is there a flag or additional field I can specify to set the height specific to this command?

Currently the height of preview window is only equivalent to the number of items in the 'search' part of fzf. For example: Screenshot 2024-07-08 at 09 50 49
In this the file Main.java is 17 lines long however the window shows only first 3 lines, despite the window being 'scrollable' I was wondering if there is a way to configure the preview window to show more of the file.

I've tried reading through the repo itself but I kind of new to zsh as a whole so I couldn't really find a way to set it. I've tried editting the $FZF_DEFAULT_OPS variable in case that did something, but I'm still stumped.

It would be great is there way I could just specific the height like:

zstyle ':fzf-tab:complete:bat:*' fzf-preview --height=10 '[[ -d "$realpath" ]] && ls --color "$realpath" || bat --style=numbers --color=always "$realpath"'

Additional infomation I'm using zsh shell on MacOS using iTerm as my terminal.

I also load the extension using zinit:

zinit light Aloxaf/fzf-tab
JeremyChuaWX commented 2 months ago

I used the following zstyle, hope it helps. Here is where it is located in the docs.

zstyle ':fzf-tab:*' fzf-flags '--height=70%'

I find it a bit confusing as well, as some flags set in FZF_DEFAULT_OPTS are inherited, and some are not.

For example, I set bindings in my FZF_DEFAULT_OPTS and they appear in the fzf window spawned by fzf-tab. However, the --height flag is not inherited and had to be set separately as shown above.

mxcury commented 2 months ago

Thank you so muchm this was just what I was looking for! Those docs definitely come in handy!