Skip to content

Conversation

zyoNoob
Copy link

@zyoNoob zyoNoob commented Mar 29, 2025

Fix: Consistent fzf-tmux Handling and Option Passing

Problem

At present the plugin doesn't work properly with fzf installations that lack the fzf-tmux binary, and the fzf --tmux support is not working.

Replicating the problem

Environment

  • system-details :
zyon@zyon-ubuntu
----------------
OS: Ubuntu 24.04.2 LTS x86_64
Kernel: 6.11.0-21-generic
Uptime: 3 hours, 14 mins
Packages: 2702 (dpkg), 7 (flatpak), 13 (snap)
Shell: zsh 5.9
Resolution: 2880x1620, 3840x2160
WM: i3
Theme: catppuccin-mocha-blue-standard+default [GTK2/3]
Icons: Papirus-Dark [GTK2/3]
Terminal: tmux
CPU: 11th Gen Intel i5-11600K (12) @ 4.900GHz
GPU: NVIDIA GeForce RTX 3060 Ti Lite Hash Rate
GPU: Intel RocketLake-S GT1 [UHD Graphics 750]
Memory: 7580MiB / 31853MiB
  • fzf = 0.60.0 (built from source with default options)
  • fzf-tmux = None (as fzf supports --tmux)
  • zoxide = 0.9.7
  • tmux = 3.4
  • bat = 0.25.0

.config/tmux/tmux.conf

set-window-option -g mode-keys vi

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

#set -g @plugin '/home/zyon/workspace/dev/tmux-sessionx'
set -g @plugin 'omerxx/tmux-sessionx'
set -g @plugin 'omerxx/tmux-floax'

set -g @sessionx-bind 'o'
set -g @sessionx-fzf-builtin-tmux 'on'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin '[email protected]:user/plugin'
# set -g @plugin '[email protected]:user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.config/tmux/plugins/tpm/tpm'

Expected Behavior

When the user presses the hotkey in a tmux session - in my case <tmux-prefix>+o a tmux-sessionx window should open

Actual Behavior

Nothing happens, no tmux-sessionx window spawns and no errors get logged in tmux log file either.

How error was traced

modified run_plugin() insessionx.sh to print out the args

run_plugin() {
	LOG_FILE="${CURRENT_DIR}/sessionx_debug.log"
	echo "$(date '+%Y-%m-%d %H:%M:%S') ======= run_plugin started =======" >> "$LOG_FILE"
	
	echo "$(date '+%Y-%m-%d %H:%M:%S') Current session: $CURRENT" >> "$LOG_FILE"
	echo "$(date '+%Y-%m-%d %H:%M:%S') Z_MODE: $Z_MODE" >> "$LOG_FILE"
	
	echo "$(date '+%Y-%m-%d %H:%M:%S') Evaluating tmux options..." >> "$LOG_FILE"
	eval $(tmux show-option -gqv @sessionx-_built-args)
	echo "$(date '+%Y-%m-%d %H:%M:%S') Built args evaluated" >> "$LOG_FILE"
	
	eval $(tmux show-option -gqv @sessionx-_built-extra-options)
	echo "$(date '+%Y-%m-%d %H:%M:%S') Built extra options evaluated" >> "$LOG_FILE"
	
	echo "$(date '+%Y-%m-%d %H:%M:%S') Calling handle_input..." >> "$LOG_FILE"
	handle_input
	echo "$(date '+%Y-%m-%d %H:%M:%S') handle_input completed" >> "$LOG_FILE"
	echo "$(date '+%Y-%m-%d %H:%M:%S') BACK value: $BACK" >> "$LOG_FILE"
	
	args+=(--bind "$BACK")
	echo "$(date '+%Y-%m-%d %H:%M:%S') args after adding BACK: ${args[*]}" >> "$LOG_FILE"
	echo "$(date '+%Y-%m-%d %H:%M:%S') fzf_opts: ${fzf_opts[*]}" >> "$LOG_FILE"
	echo "$(date '+%Y-%m-%d %H:%M:%S') INPUT value: $INPUT" >> "$LOG_FILE"
	echo "$(date '+%Y-%m-%d %H:%M:%S') FZF_BUILTIN_TMUX: $FZF_BUILTIN_TMUX" >> "$LOG_FILE"

	if [[ "$FZF_BUILTIN_TMUX" == "on" ]]; then
		echo "$(date '+%Y-%m-%d %H:%M:%S') Using built-in fzf..." >> "$LOG_FILE"
		RESULT=$(echo -e "${INPUT}" | sed -E 's/✗/ /g' | fzf "${fzf_opts[@]}" "${args[@]}" | tail -n1)
		echo "$(date '+%Y-%m-%d %H:%M:%S') fzf completed with exit code: $?" >> "$LOG_FILE"
	else
		echo "$(date '+%Y-%m-%d %H:%M:%S') Using fzf-tmux..." >> "$LOG_FILE"
		RESULT=$(echo -e "${INPUT}" | sed -E 's/✗/ /g' | fzf-tmux "${fzf_opts[@]}" "${args[@]}" | tail -n1)
		echo "$(date '+%Y-%m-%d %H:%M:%S') fzf-tmux completed with exit code: $?" >> "$LOG_FILE"
	fi
	
	echo "$(date '+%Y-%m-%d %H:%M:%S') RESULT: $RESULT" >> "$LOG_FILE"
	echo "$(date '+%Y-%m-%d %H:%M:%S') ======= run_plugin ended =======" >> "$LOG_FILE"
}

Log Output

Invoking the sessionx plugin via the hotkey defined in configuration file generated this output in the logfile -

2025-03-29 16:28:31 ======= run_plugin started =======
2025-03-29 16:28:31 Current session: default
2025-03-29 16:28:31 Z_MODE: off
2025-03-29 16:28:31 Evaluating tmux options...
2025-03-29 16:28:31 Built args evaluated
2025-03-29 16:28:31 Built extra options evaluated
2025-03-29 16:28:31 Calling handle_input...
2025-03-29 16:28:31 handle_input completed
2025-03-29 16:28:31 BACK value: ctrl-b:reload(echo -e "")+change-preview(/home/zyon/.config/tmux/plugins/tmux-sessionx/scripts/preview.sh {1})
2025-03-29 16:28:31 args after adding BACK: --bind ctrl-t:change-preview(/home/zyon/.config/tmux/plugins/tmux-sessionx/scripts/preview.sh -t {1}) --bind ctrl-x:reload(find /home/zyon/.config -mindepth 1 -maxdepth 1 -type d -o -type l)+change-preview(ls {}) --bind ctrl-w:reload(tmux list-windows -a -F '#{session_name}:#{window_name}')+change-preview(/home/zyon/.config/tmux/plugins/tmux-sessionx/scripts/preview.sh -w {1}) --bind ctrl-e:reload(find /home/zyon -mindepth 1 -maxdepth 1 -type d -o -type l)+change-preview(ls {}) --bind ctrl-f:reload(zoxide query -l)+change-preview(ls {}) --bind alt-bspace:execute-silent(tmux kill-session -t {})+reload(/home/zyon/.config/tmux/plugins/tmux-sessionx/scripts/reload_sessions.sh) --bind bspace:backward-delete-char --bind esc:abort --bind ctrl-n:up --bind ctrl-p:down --bind enter:replace-query+print-query --bind ctrl-u:preview-half-page-up --bind ctrl-d:preview-half-page-down --bind ctrl-r:execute(bash -c ' printf >&2 "New name: ";read name; tmux rename-session -t {1} "\"; ')+reload(bash -c ' tmux list-sessions | sed -E "s/:.*$//"; ') --bind ?:toggle-preview --bind change:first --exit-0 --header=enter=󰿄  alt-bspace=󱂧  ctrl-r=󰑕  ctrl-x=󱃖  ctrl-w=  ctrl-e=󰇘  ctrl-b=󰌍  ctrl-t=󰐆  ctrl-u=  ctrl-d= / ctrl-f= --preview=/home/zyon/.config/tmux/plugins/tmux-sessionx/scripts/preview.sh {} --preview-window=top,75%,, --layout=default --pointer=▶ --tmux 75%,75% --prompt   --print-query --tac --scrollbar ▌▐ --border-label Current session: ""  --bind focus:transform-preview-label:echo [ {} ] --bind ctrl-b:reload(echo -e "")+change-preview(/home/zyon/.config/tmux/plugins/tmux-sessionx/scripts/preview.sh {1})
2025-03-29 16:28:31 fzf_opts: 
2025-03-29 16:28:31 INPUT value: 
2025-03-29 16:28:31 FZF_BUILTIN_TMUX: 
2025-03-29 16:28:31 Using fzf-tmux...
2025-03-29 16:28:31 fzf-tmux completed with exit code: 0
2025-03-29 16:28:31 RESULT: 
2025-03-29 16:28:31 ======= run_plugin ended =======

Conclusion

As can be seen from above log, for some reason args set in the sessionx.tmux are not passed to the sessionx.sh script. This is a bug, and since my gripe was with how the fzf call was being handled, I have opened this PR to fix the issue. There may still be some issues with other args, not that I ran into them given this is my first time even using this plugin.

This PR fixes the usage of args in the fzf calls.

Major Change:

Refactors the handling of fzf-tmux vs. fzf --tmux calls. Instead of setting size parameters in sessionx.tmux, the size parameters and the fzf-builtin-tmux setting are now passed through to sessionx.sh via extra_options array. The sessionx.sh script then uses these options to correctly execute either fzf with the --tmux parameter or fzf-tmux with the -p

Fixes:

Resolves inconsistencies in how the user can configure sessionx to plain fzf in tmux rather than fzf-tmux. This provides more flexibility better handles scenarios where older versions of fzf are present.

@LucaZulberti
Copy link

This is needed, is the plugin not maintained anymore?

@zyoNoob
Copy link
Author

zyoNoob commented Aug 13, 2025

Looks like it's still being maintained but only on life support mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants