claude-memory/graph/configurations/cc-tmux-alias-auto-launch-claude-with-nesting-support-ae6741.md

1.3 KiB

id type title tags importance confidence created updated
ae674150-d714-452a-bc65-7f866b45c8a9 configuration cc() tmux alias: auto-launch Claude with nesting support
tmux
zshrc
alias
claude-code
homelab
configuration
0.55 0.8 2026-02-26T18:43:50.686761+00:00 2026-02-26T18:43:50.686761+00:00

cc() tmux alias: auto-launch Claude with nesting support

Context

Cal's ~/.zshrc has a cc() function for quickly launching Claude Code inside a named tmux session.

Final Implementation

cc() {
  local name="${1:-$(basename $PWD)}"
  if [ -n "$TMUX" ]; then
    tmux new -ds "$name" "claude" 2>/dev/null || tmux switch-client -t "$name"
    tmux switch-client -t "$name"
  else
    tmux new -s "$name" -A "claude"
  fi
}

Key Behaviors

  • Auto-names session from current directory basename if no argument given
  • Launches claude automatically inside the new session
  • If already inside tmux ($TMUX is set): creates a detached session and switches to it, avoiding nested tmux
  • If not in tmux: creates or attaches (-A) to the named session
  • The 2>/dev/null || switch-client pattern handles the case where the session already exists

Notes

  • Cal's terminal (Warp or similar) may auto-start tmux on login, so the nesting check is important in practice
  • cc project-name overrides the auto-naming behavior