dotfiles/scripts/bin/tmux-claude-code.sh

23 lines
792 B
Bash
Executable file

#!/usr/bin/env bash
# tmux-claude-code.sh - Smart Claude Code launcher for tmux
#
# Finds existing Claude Code tmux window or creates new one
# Usage: tmux-claude-code.sh
# Check if Claude Code is running in tmux
CLAUDE_WINDOW=$(tmux list-windows -F '#{window_name}' 2>/dev/null | grep -iE "claude|code" | head -1)
if [ -n "$CLAUDE_WINDOW" ]; then
# Found existing window - switch to it
tmux select-window -t "$CLAUDE_WINDOW"
# Focus the Ghostty window
wmctrl -a ghostty 2>/dev/null || xdotool search --class ghostty windowactivate 2>/dev/null
echo "Switched to existing Claude Code window: $CLAUDE_WINDOW"
else
# No Claude Code window found - create new tmux window
tmux new-window -n "claude-code" "claude-code"
echo "Created new Claude Code window"
fi