From 381132c1d8398fe51dba985509f66b2227e96d97 Mon Sep 17 00:00:00 2001 From: Hamzeh Pourmahdi Date: Wed, 1 Jan 2025 14:08:58 +0330 Subject: [PATCH] feat: add option to change tmux popup window factor for device which is not proprly populate the window, and use stock with half size window --- README.md | 6 ++++++ lib/-ftb-fzf | 2 ++ lib/ftb-tmux-popup | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 09ba6c6..16eda33 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,12 @@ If you're using tmux >= 3.2, we provide a script `ftb-tmux-popup` to make full u zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup ``` +if tmux popup is not populated in proper size you can change it's resize factor for wider window +```zsh +# default is 5 +zstyle ':fzf-tab:*' fzf-tmux-width-factor 25 +``` + BTW, you can also use this script outside the fzf-tab. ```zsh diff --git a/lib/-ftb-fzf b/lib/-ftb-fzf index 926814b..b069e06 100755 --- a/lib/-ftb-fzf +++ b/lib/-ftb-fzf @@ -41,6 +41,7 @@ local ret=0 -ftb-zstyle -s fzf-pad fzf_pad || fzf_pad=2 -ftb-zstyle -s fzf-min-height fzf_min_height || fzf_min_height=0 -ftb-zstyle -b use-fzf-default-opts use_fzf_default_opts || use_fzf_default_opts="no" +-ftb-zstyle -s fzf-tmux-width-factor fzf_tmux_width_factor || fzf_tmux_width_factor=5 -ftb-zstyle -a debug-command debug_command && { ${(eX)debug_command} $fzf_flags @@ -96,6 +97,7 @@ FZF_DEFAULT_OPTS=$fzf_default_opts SHELL=$ZSH_NAME $fzf_command \ --expect=$continuous_trigger,$print_query,$accept_line \ --header-lines=$header_lines \ --height=${FZF_TMUX_HEIGHT:=$(( min(max(lines, fzf_min_height), LINES / 3 * 2) ))} \ + --width=${FZF_TMUX_WIDTH:-80} \ --layout=reverse \ --multi \ --nth=2,3 \ diff --git a/lib/ftb-tmux-popup b/lib/ftb-tmux-popup index c2416dc..0e122df 100755 --- a/lib/ftb-tmux-popup +++ b/lib/ftb-tmux-popup @@ -84,7 +84,7 @@ else fi # calculate the popup width and x position -popup_width=$(( min(max(comp_length + 5, popup_min_size[1]), window_width) )) +popup_width=$(( min(max(comp_length + fzf_tmux_width_factor, popup_min_size[1]), window_width) )) popup_x=$(( cursor_x + popup_width > window_width ? window_width - popup_width : cursor_x )) echo -E "env FZF_DEFAULT_OPTS='' SHELL=$ZSH_NAME $commands[fzf] ${(qq)fzf_opts[@]} < $tmp_dir/completions.$$ > $tmp_dir/result-$$" > $tmp_dir/fzf-$$