MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / execIntoTmuxWorktree

Function execIntoTmuxWorktree

src/utils/worktree.ts:1182–1518  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

1180 * This is called early in cli.tsx before loading the full CLI.
1181 */
1182export async function execIntoTmuxWorktree(args: string[]): Promise<{
1183 handled: boolean
1184 error?: string
1185}> {
1186 // Check platform - tmux doesn't work on Windows
1187 if (process.platform === 'win32') {
1188 return {
1189 handled: false,
1190 error: 'Error: --tmux is not supported on Windows',
1191 }
1192 }
1193
1194 // Check if tmux is available
1195 const tmuxCheck = spawnSync('tmux', ['-V'], { encoding: 'utf-8' })
1196 if (tmuxCheck.status !== 0) {
1197 const installHint =
1198 process.platform === 'darwin'
1199 ? 'Install tmux with: brew install tmux'
1200 : 'Install tmux with: sudo apt install tmux'
1201 return {
1202 handled: false,
1203 error: `Error: tmux is not installed. ${installHint}`,
1204 }
1205 }
1206
1207 // Parse worktree name and tmux mode from args
1208 let worktreeName: string | undefined
1209 let forceClassicTmux = false
1210 for (let i = 0; i < args.length; i++) {
1211 const arg = args[i]
1212 if (!arg) continue
1213 if (arg === '-w' || arg === '--worktree') {
1214 // Check if next arg exists and isn't another flag
1215 const next = args[i + 1]
1216 if (next && !next.startsWith('-')) {
1217 worktreeName = next
1218 }
1219 } else if (arg.startsWith('--worktree=')) {
1220 worktreeName = arg.slice('--worktree='.length)
1221 } else if (arg === '--tmux=classic') {
1222 forceClassicTmux = true
1223 }
1224 }
1225
1226 // Check if worktree name is a PR reference
1227 let prNumber: number | null = null
1228 if (worktreeName) {
1229 prNumber = parsePRReference(worktreeName)
1230 if (prNumber !== null) {
1231 worktreeName = `pr-${prNumber}`
1232 }
1233 }
1234
1235 // Generate a slug if no name provided
1236 if (!worktreeName) {
1237 const adjectives = ['swift', 'bright', 'calm', 'keen', 'bold']
1238 const nouns = ['fox', 'owl', 'elm', 'oak', 'ray']
1239 const adj = adjectives[Math.floor(Math.random() * adjectives.length)]

Callers 1

mainFunction · 0.85

Calls 13

parsePRReferenceFunction · 0.85
validateWorktreeSlugFunction · 0.85
hasWorktreeCreateHookFunction · 0.85
getCwdFunction · 0.85
worktreePathForFunction · 0.85
getOrCreateWorktreeFunction · 0.85
performPostCreationSetupFunction · 0.85
worktreeBranchNameFunction · 0.85
isInITerm2Function · 0.85
errorMessageFunction · 0.70
toStringMethod · 0.65

Tested by

no test coverage detected