Created
August 26, 2022 01:30
-
-
Save SidharthArya/07c373ef7e30bd43fc718716201569eb to your computer and use it in GitHub Desktop.
Simple tmux fzf for pane window and sessions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bind-key s display-popup -E "bash tmux_fzf.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export IFS=$'\n'; | |
export SELECTION=$(for i in $(tmux list-sessions -F "#{session_name}: #{pane_current_command}"); | |
do | |
echo $i; | |
export SESSION=$(echo $i | sed 's/:.*//g'); | |
for j in $(tmux list-window -F "#{window_index} #{pane_current_command}" -t $SESSION); | |
do | |
echo $j | xargs echo - $SESSION ; | |
done; | |
for j in $(tmux list-pane -F "#{window_index}.#{pane_index} #{pane_current_command}" -s -t $SESSION); | |
do | |
echo $j | xargs echo -- $SESSION; | |
done; | |
done | fzf) | |
if [[ "$SELECTION" == "-- "* ]]; | |
then | |
export SESSION=$(echo $SELECTION | awk '{print $2}'); | |
export PANE=$(echo $SELECTION | awk '{print $3}' | tr -d ':'); | |
export WINDOW=$(echo $SELECTION| awk '{print $3}' | tr -d ':'); | |
tmux switch-client -t $SESSION; | |
tmux select-window -t $WINDOW; | |
tmux select-pane -t $PANE; | |
elif [[ "$SELECTION" == "- "* ]]; | |
then | |
export SESSION=$(echo $SELECTION | awk '{print $2}'); | |
export WINDOW=$(echo $SELECTION | awk '{print $3}'); | |
tmux switch-client -t $SESSION; | |
tmux select-window -t $WINDOW; | |
else | |
export SESSION=$(echo $SELECTION | sed 's/: .*//g'); | |
tmux switch-client -t $SESSION; | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment