Skip to content

kargnas/vscode-ext-tmux-worktree

Repository files navigation

TMUX Worktree

Seamlessly manage tmux sessions alongside git worktrees โ€” right from VS Code.

VS Marketplace Blog

๐ŸŒ Read this in other languages: English | ํ•œ๊ตญ์–ด | ็ฎ€ไฝ“ไธญๆ–‡ | ็น้ซ”ไธญๆ–‡ (ๅฐ็ฃ) | ็น้ซ”ไธญๆ–‡ (้ฆ™ๆธฏ) | ๆ—ฅๆœฌ่ชž

Install from VS Marketplace

TMUX Worktree Screenshot

Why It Feels Polished

  • Image-aware terminal paste: Cmd+V / Ctrl+Shift+V keeps normal text paste, but auto-inserts an image file path when clipboard has an image.
  • Remote-SSH clipboard bridge: local clipboard images can be pasted into remote terminals without manual upload steps.
  • Collision-safe session identity: sessions use repo-name + path hash namespace and slug disambiguation for same-name repos and similar paths.
  • Legacy-compatible migration: previous session prefixes are still detected when @workdir belongs to the repo.
  • No-git fallback visibility: even non-git folders still appear as current project (no git) instead of disappearing from the tree.

Why?

If you use git worktree for parallel development and tmux for persistent terminal sessions, you know the pain of manually juggling both. This extension bridges the gap:

  • One click to create a worktree + tmux session together
  • Tree view showing all worktrees with their tmux status
  • Auto-attach to the right tmux session when you open a worktree
  • Never lose context โ€” sessions persist even if VS Code closes

Perfect for AI Coding Agents

Run AI coding agents (Claude Code, Codex, OpenCode, Gemini CLI) inside tmux sessions. Your agent keeps running in the background โ€” reconnect from anywhere, even from a phone via Termux.

Real-World Use Cases

๐Ÿค– Parallel Development with AI Agents

project/
โ”œโ”€โ”€ main              โ†’ tmux: "myapp/main" (Claude Code refactoring)
โ”œโ”€โ”€ feature/oauth     โ†’ tmux: "myapp/feature-oauth" (manual coding)
โ””โ”€โ”€ fix/memory-leak   โ†’ tmux: "myapp/fix-memory-leak" (Codex analyzing)

Run independent AI agents on each branch, check results in VS Code. Sessions keep working in the background.

๐ŸŒ Remote Server Development Connected to a dev server via SSH:

  • Use VS Code Remote-SSH to connect
  • Manage branch sessions with TMUX Worktree
  • SSH disconnect? tmux sessions persist
  • Reconnect from home, cafรฉ, or phone

๐Ÿ“ฑ Mobile Code Review Access from phone via Termux + SSH:

ssh dev-server
tmux attach -t myapp/feature-oauth

Review AI-written code during your commute.

Features

๐ŸŒณ Explorer View

A dedicated sidebar showing all your git worktrees and their associated tmux sessions at a glance. See session status, pane count, and last activity time.

โšก One-Click Task Creation

Create a new git branch + worktree + tmux session in one step. Start working on a new feature instantly.

๐Ÿ”— Smart Attach

  • Attach in Terminal โ€” open tmux session in VS Code's integrated terminal
  • Attach in Editor โ€” embed tmux session as an editor tab
  • Auto-attach โ€” automatically connect when opening a worktree folder

๐Ÿงน Orphan Cleanup

Detect and clean up tmux sessions that no longer have matching worktrees. Keep your environment tidy.

๐Ÿ–ฅ๏ธ Session Management

  • Split panes and create new windows from the context menu
  • Copy worktree paths to clipboard
  • Open worktrees in new VS Code windows
  • Filter sessions by name

๐Ÿ“‹ Smart Paste (Image-Aware Terminal Paste)

  • Cmd+V (macOS) / Ctrl+Shift+V (Linux) in terminal first checks clipboard content
  • If clipboard has text, it keeps the default paste behavior
  • If clipboard has an image, it saves a temporary .png and inserts the file path into terminal
  • Works with local sessions and Remote-SSH (webview bridge uploads local clipboard image to remote host)
  • Force image-only mode from Command Palette: TMUX: Paste Image from Clipboard

๐Ÿงญ Robust Session Mapping

  • Session namespace uses repo-name + path hash to avoid collisions between same-name repositories in different directories
  • Legacy session names are still detected for compatibility when @workdir points inside the current repo
  • Worktrees with colliding slugs are auto-disambiguated (parent folder, then path hash)
  • Non-git folders are still shown in the tree as current project (no git)

Commands

Command Description
TMUX: Attach/Create Session Attach to or create a tmux session for the current worktree
TMUX: New Task Create a new branch + worktree + tmux session
TMUX: Remove Task Remove a worktree and its tmux session
TMUX: Cleanup Orphans Remove orphaned tmux sessions
TMUX: Smart Paste (Image Support) Smart terminal paste: text uses normal paste, image inserts temporary file path
TMUX: Paste Image from Clipboard Force image paste and insert the saved image path into the active terminal

Recent Updates (v1.1.2 - v1.1.6)

  • v1.1.6: Added image-aware terminal paste for AI CLI workflows (Cmd+V / Ctrl+Shift+V) and a force image paste command. Also improved startup auto-attach sizing stability to reduce occasional small terminal rendering until a manual window resize.
  • v1.1.4 - v1.1.5: Improved tmux clipboard reliability by enabling clipboard capabilities and passthrough options during attach.
  • v1.1.3: Refactored legacy session-prefix compatibility logic for safer migration.
  • v1.1.2: Added slug collision handling and explicit no-git workspace labeling (current project (no git)).

Requirements

  • tmux โ€” must be installed and available in PATH
  • git โ€” must be installed and available in PATH
  • VS Code 1.85.0+

Getting Started

  1. Install the extension
  2. Open a git repository in VS Code
  3. Click the TMUX icon in the Activity Bar (sidebar)
  4. Your existing worktrees and tmux sessions will appear automatically

To create a new task: click the + button in the TMUX panel header, enter a branch name, and you're ready to go.

How It Works

Repository (root)
โ”œโ”€โ”€ main              โ†’ tmux session: "project-a1b2c3d4_main"
โ”œโ”€โ”€ feature/login     โ†’ tmux session: "project-a1b2c3d4_feature-login"
โ””โ”€โ”€ fix/bug-123       โ†’ tmux session: "project-a1b2c3d4_fix-bug-123"

Each worktree gets a dedicated tmux session. Session names use a repo namespace (repo-name + path hash) plus a slug, which avoids collisions across same-name repositories in different directories.

Learn More

License

MIT

Packages

 
 
 

Contributors

Languages