Created
November 15, 2023 10:16
-
-
Save naranyala/0477051caaf752ab06a9b1c45fa234bc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# INFO: | |
# using fzf to show jump between tmux-window | |
# Get a list of active tmux sessions | |
tmux_sessions=$(tmux list-sessions -F "#S") | |
# Check if there are no active sessions | |
if [ -z "$tmux_sessions" ]; then | |
echo "No active tmux sessions found." | |
exit 1 | |
fi | |
# Use fzf to select a tmux session | |
selected_session=$(echo "$tmux_sessions" | fzf --prompt="Select a tmux session: ") | |
# Check if a selection is made | |
if [ -n "$selected_session" ]; then | |
# Get a list of windows in the selected session | |
tmux_windows=$(tmux list-windows -t "$selected_session" -F "#I:#W") | |
if [ -z "$tmux_windows" ]; then | |
echo "No windows found in session '$selected_session'. Exiting." | |
exit 1 | |
fi | |
# Use fzf to select a window | |
selected_window=$(echo "$tmux_windows" | fzf --prompt="Select a window: " | cut -d ':' -f1) | |
if [ -n "$selected_window" ]; then | |
# Jump to the selected tmux window | |
tmux switch-client -n -t "$selected_session:$selected_window" | |
echo "Jumped to window '$selected_window' in session '$selected_session'." | |
else | |
echo "No window selected. Exiting." | |
exit 1 | |
fi | |
else | |
echo "No session selected. Exiting." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment