store: cc() tmux alias: auto-launch Claude with nesting support
This commit is contained in:
parent
ece4eaddfa
commit
a6d7fd4794
@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
id: ae674150-d714-452a-bc65-7f866b45c8a9
|
||||||
|
type: configuration
|
||||||
|
title: "cc() tmux alias: auto-launch Claude with nesting support"
|
||||||
|
tags: [tmux, zshrc, alias, claude-code, homelab, configuration]
|
||||||
|
importance: 0.55
|
||||||
|
confidence: 0.8
|
||||||
|
created: "2026-02-26T18:43:50.686761+00:00"
|
||||||
|
updated: "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
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
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
|
||||||
Loading…
Reference in New Issue
Block a user