Skip to content

Commit

Permalink
feat: add option to change tmux popup window factor for device which …
Browse files Browse the repository at this point in the history
…is not proprly populate the window, and use stock with half size window
  • Loading branch information
hamzeh-pm committed Jan 1, 2025
1 parent 6aced3f commit 381132c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/-ftb-fzf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion lib/ftb-tmux-popup
Original file line number Diff line number Diff line change
Expand Up @@ -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-$$
Expand Down

0 comments on commit 381132c

Please sign in to comment.