Skip to main content

Automate opening of new tabs and windows in terminal programs

Project description

automate-terminal

Automate opening of new tabs and windows in terminal programs. Currently supports iTerm2, Terminal.app, and Ghostty on macOS, with additional terminals and OSes added by request.

automate-terminal is a best-effort project. Some terminals do not support automation at all!

Installation

pip install automate-terminal
mise install pip:automate-terminal

Or install from source:

git clone https://github.com/yourusername/automate-terminal.git
cd automate-terminal
pip install -e .

Supported Terminals

Terminal New Tabs/Windows Switch by ID Switch by Working Dir List Sessions Paste Commands
iTerm2
Terminal.app
Ghostty
VSCode ⚠️ (no tabs)
Cursor ⚠️ (no tabs)

Other terminals are not supported; automate-terminal will exit with an error code in other terminals.

Quick Start

# Check if your terminal is supported
automate-terminal check

# Create a new tab
automate-terminal new-tab /path/to/project

# Switch to existing session by directory
automate-terminal switch-to --working-directory=/path/to/project

# Create new window with initialization script
automate-terminal new-window /path/to/project \
  --paste-and-run="source .env && npm run dev"

Commands

check

Detect terminal capabilities.

automate-terminal check
automate-terminal check --output=json

switch-to

Switch to existing session. Errors if not found.

# By working directory (or use --wd alias)
automate-terminal switch-to --working-directory=/path/to/dir

# By session ID (or use --id alias)
automate-terminal switch-to --session-id=w0t0p2:ABC123

# Both (session ID takes precedence)
automate-terminal switch-to \
  --session-id=w0t0p2:ABC123 \
  --working-directory=/path/to/dir

# Match sessions in subdirectories
automate-terminal switch-to --working-directory=/path/to/dir --subdirectory-ok

new-tab

Create new tab.

automate-terminal new-tab /path/to/dir

new-window

Create new window.

automate-terminal new-window /path/to/dir

list-sessions

List all sessions.

automate-terminal list-sessions
automate-terminal list-sessions --output=json

Options

Output Format

  • --output=text - Human-readable (default)
  • --output=json - JSON for programmatic use
  • --output=none - Silent

Paste and Run

Execute commands after creating/switching sessions.

--paste-and-run="echo 'I run unconditionally'"
--paste-and-run-bash="echo 'I only run if the current shell is bash'"
--paste-and-run-zsh="echo 'I only run if the current shell is zsh'"
--paste-and-run-fish="echo 'I only run if the current shell is fish'"

Shell-specific flags override generic --paste-and-run when detected shell matches.

Note: Some terminals (VSCode, Cursor) cannot execute paste scripts programmatically. When using --output=json, check the paste_script_executed field to determine if you need to run the script manually:

  • true: The paste script was executed by the terminal
  • false: The paste script was provided but the terminal cannot execute it (you should run it manually)
  • Field omitted: No paste script was provided

Debug and Dry Run

--debug     # Enable debug logging to stderr
--dry-run   # Log actions instead of executing them

Use --dry-run to see what AppleScript commands would be executed without actually running them. Useful for debugging and understanding what the tool will do.

Environment Variables

AUTOMATE_TERMINAL_OVERRIDE

Force automate-terminal to use a specific terminal implementation, bypassing automatic detection.

Use case: When running from VSCode/Cursor integrated terminal, you may want to manage the underlying terminal (iTerm2, Terminal.app) instead of VSCode/Cursor itself.

Values:

  • iterm2 - Force iTerm2 implementation
  • terminal or terminal.app - Force Terminal.app implementation
  • ghostty - Force Ghostty implementation
  • vscode - Force VSCode implementation
  • cursor - Force Cursor implementation

Example:

# From VSCode integrated terminal, list iTerm2 sessions instead of VSCode windows
export AUTOMATE_TERMINAL_OVERRIDE=iterm2
automate-terminal list-sessions

# Or inline
AUTOMATE_TERMINAL_OVERRIDE=terminal automate-terminal check

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

automate_terminal-0.1.1.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

automate_terminal-0.1.1-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file automate_terminal-0.1.1.tar.gz.

File metadata

  • Download URL: automate_terminal-0.1.1.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for automate_terminal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3893fc6233cbbca80fe30203e9258560909908e6b7948743294f562cf8c29aeb
MD5 5d2ccb570bd48453e12fe5685fa3418c
BLAKE2b-256 10764f16a00a300e7602e22312b9c63ecbe743397aec1b1c22eb1b18714d9ab1

See more details on using hashes here.

Provenance

The following attestation bundles were made for automate_terminal-0.1.1.tar.gz:

Publisher: pypi.yml on irskep/automate-terminal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file automate_terminal-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for automate_terminal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2e7a150c452192f4084a5c82263e5c8062ebe5ce215b20b1582012109f0717e
MD5 1d9ff99bd53fc60ec1683a7d1c38e02e
BLAKE2b-256 7e365ed08967e719d51923035ca5d57f005cc45b78da6ed0c3159a966c6ea98e

See more details on using hashes here.

Provenance

The following attestation bundles were made for automate_terminal-0.1.1-py3-none-any.whl:

Publisher: pypi.yml on irskep/automate-terminal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page