omerxx / tmux-sessionx

A Tmux session manager, with preview, fuzzy finding, and MORE
GNU General Public License v3.0
556 stars 51 forks source link

Naming in window mode #60

Closed Zik42 closed 3 months ago

Zik42 commented 3 months ago

Feature proposal

It would be nice to add window name after index of window. So names are like - ::. Or even better - just to have :, so it can be fuzzy finded very fast. Selected can be added in the title of fzf.

I like idea of your plugin, thank you for your work <3

kszcode commented 3 months ago

Alternatively here is a bash script that can be used from inside tmux to switch between session/windows. The limitation of this script is that it does not provide a preview.

bind-key ^J run-shell -b "bash ~/tdot/bin/tmux_jj-switch-pane.sh"

#!/bin/bash

# Define the data to list for each pane
LIST_DATA="#{session_name}:#{window_id}:#{pane_id}:#{session_name}|#{window_name} #{pane_title} #{pane_current_path} #{pane_current_command}"

# Define the fzf-tmux command with desired options
FZF_COMMAND="fzf-tmux -p --delimiter=: --with-nth 4.. --color=hl:2"
# FZF_COMMAND="fzf-tmux -p "

# Generate the list of panes and pass it to fzf-tmux for selection
TARGET=$(tmux list-panes -a -F "$LIST_DATA" | $FZF_COMMAND)

# echo TARGET=$TARGET

# Extract only the session, window, and pane IDs
# IFS stands for the Internal Field Separator. It is a shell variable used to define the character or characters used to separate a pattern into tokens for some operations. In this case, IFS=: sets the colon (:) as the delimiter.
IFS=: read -r session window pane rest <<< "$TARGET"
# echo session=$session
# echo window=$window
# echo pane=$pane
# echo rest=$rest

# Ensure session, window, and pane are selected before attempting to switch
if [ -n "$pane" ]; then
    # tmux select-pane -t "$session:$window.$pane"
    tmux switch-client -t "$session:$window.$pane"
fi

exit 0
omerxx commented 3 months ago

@Zik42 Does the fix above solves this issue?

Zik42 commented 3 months ago

@omerxx Yeah, that is it! But I can not make it work right now, did update plugin via tpm and restarted tmux... I will check later