it2


Nameit2 JSON
Version 0.1.8 PyPI version JSON
download
home_pageNone
SummaryA powerful command-line interface for controlling iTerm2
upload_time2025-07-13 16:34:41
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2025 mkusaka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords automation cli iterm2 macos terminal
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # it2

A powerful command-line interface for controlling iTerm2 using its Python API.

## Features

- **Session Management**: Send text, execute commands, split panes, manage sessions
- **Window Control**: Create, move, resize, and manage windows
- **Tab Operations**: Create and navigate between tabs
- **Profile Management**: List, create, and apply iTerm2 profiles
- **Broadcasting**: Send input to multiple sessions simultaneously
- **Monitoring**: Watch session output, keystrokes, and variables in real-time
- **Configuration**: Define custom profiles and aliases in YAML
- **Shortcuts**: Quick access to common commands

## Requirements

- macOS with iTerm2 3.3.0 or later
- Python 3.8+
- iTerm2 Python API enabled (Preferences > General > Magic > Enable Python API)

## Installation

### Using pip

```bash
pip install it2
```

### Using uvx (recommended)

```bash
uvx it2
```

## Quick Start

```bash
# Send text to current session
it2 send "Hello, World!"

# Run a command
it2 run "ls -la"

# Split the current pane vertically
it2 vsplit

# Create a new window
it2 new

# List all sessions
it2 ls
```

## Basic Usage

### Session Operations

```bash
# Send text (without newline)
it2 session send "text"
it2 send "text"  # shortcut

# Execute command (with newline)
it2 session run "command"
it2 run "command"  # shortcut

# Target specific session or all sessions
it2 send "text" --session <id>
it2 send "text" --all

# Split panes
it2 session split          # horizontal split
it2 session split -v       # vertical split
it2 vsplit                 # shortcut for vertical split

# Session management
it2 session list           # list all sessions
it2 session close          # close current session
it2 session restart        # restart session
it2 session clear          # clear screen
```

### Window Operations

```bash
# Window management
it2 window new             # create new window
it2 window list            # list all windows
it2 window close           # close current window
it2 window focus <id>      # focus specific window

# Window manipulation
it2 window move 100 200    # move to position
it2 window resize 800 600  # resize window
it2 window fullscreen on   # enable fullscreen

# Window arrangements
it2 window arrange save "dev"      # save arrangement
it2 window arrange restore "dev"   # restore arrangement
```

### Tab Operations

```bash
# Tab management
it2 tab new                # create new tab
it2 tab list               # list all tabs
it2 tab close              # close current tab
it2 tab select <id>        # select specific tab

# Tab navigation
it2 tab next               # go to next tab
it2 tab prev               # go to previous tab
it2 tab goto 2             # go to tab by index
```

### Profile Operations

```bash
# Profile management
it2 profile list           # list all profiles
it2 profile show "Default" # show profile details
it2 profile create "MyProfile" --base "Default"
it2 profile apply "MyProfile"

# Profile configuration
it2 profile set "MyProfile" font-size 14
it2 profile set "MyProfile" bg-color "#000000"
it2 profile set "MyProfile" transparency 0.9
```

### Application Control

```bash
# App management
it2 app activate           # bring iTerm2 to front
it2 app hide               # hide iTerm2
it2 app theme dark         # set theme

# Broadcasting
it2 app broadcast on       # enable broadcasting
it2 app broadcast off      # disable broadcasting
it2 app broadcast add session1 session2  # create broadcast group
```

### Monitoring

```bash
# Monitor output
it2 monitor output -f                      # follow output
it2 monitor output -f -p "ERROR"           # filter by pattern

# Monitor keystrokes
it2 monitor keystroke                      # all keystrokes
it2 monitor keystroke -p "^[a-z]+$"        # filter by regex

# Monitor variables
it2 monitor variable lastCommand           # session variable
it2 monitor variable buildNumber --app     # app variable

# Monitor prompts (requires shell integration)
it2 monitor prompt
```

## Configuration

Create `~/.it2rc.yaml` to define custom profiles and aliases:

```yaml
# Custom profiles
profiles:
  dev:
    - command: cd ~/project
    - split: vertical
    - pane1: npm run dev
    - pane2: npm test --watch
  
  servers:
    - split: 2x2
    - pane1: ssh server1
    - pane2: ssh server2
    - pane3: ssh server3
    - pane4: ssh server4

# Command aliases
aliases:
  deploy: session run "deploy.sh" --all
  logs: monitor output -f -p "ERROR|WARN"
  dev-setup: load dev
```

Use configurations:

```bash
# Load a profile
it2 load dev

# Execute an alias
it2 alias deploy

# Show config path
it2 config-path

# Reload configuration
it2 config-reload
```

## Advanced Examples

### Development Environment Setup

```bash
# Create a development workspace
it2 window new --profile "Development"
it2 split
it2 send "cd ~/project && npm run dev"
it2 session focus 2
it2 send "cd ~/project && npm test --watch"
```

### Multi-Server Management

```bash
# SSH to multiple servers with broadcasting
it2 tab new
it2 split && it2 split && it2 split
it2 app broadcast on
it2 send "ssh production-server"
```

### Automated Deployment

Create a deployment script:

```bash
#!/bin/bash
# deploy.sh

# Create deployment window
it2 window new --profile "Deploy"

# Split for monitoring
it2 split -v

# Start deployment in first pane
it2 send "cd ~/project && ./deploy-prod.sh"

# Monitor logs in second pane
it2 session focus 2
it2 run "tail -f /var/log/deploy.log"

# Watch for errors
it2 monitor output -f -p "ERROR|FAILED"
```

## Environment Variables

- `IT2_DEFAULT_PROFILE`: Default profile name
- `IT2_CONFIG_PATH`: Path to configuration file (default: `~/.it2rc.yaml`)
- `IT2_TIMEOUT`: Command timeout in seconds

## Error Codes

- `0`: Success
- `1`: General error
- `2`: Connection error (iTerm2 not running or API not enabled)
- `3`: Target not found (session/window/tab not found)
- `4`: Invalid arguments

## Development

### Setup Development Environment

```bash
# Clone the repository
git clone https://github.com/mkusaka/it2.git
cd it2

# Create virtual environment
python -m venv venv
source venv/bin/activate

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
ruff check .
black --check .
mypy .
```

### Project Structure

```
it2/
├── src/
│   └── it2/
│       ├── __init__.py
│       ├── cli.py              # Main CLI entry point
│       ├── commands/           # Command modules
│       │   ├── session.py
│       │   ├── window.py
│       │   ├── tab.py
│       │   ├── profile.py
│       │   ├── app.py
│       │   ├── monitor.py
│       │   ├── shortcuts.py
│       │   └── config_commands.py
│       ├── core/               # Core functionality
│       │   ├── connection.py
│       │   ├── session_handler.py
│       │   └── errors.py
│       └── utils/              # Utilities
│           └── config.py
├── tests/                      # Test files
├── pyproject.toml              # Project configuration
├── README.md                   # This file
└── example.it2rc.yaml          # Example configuration
```

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

MIT License - see [LICENSE](LICENSE) for details.

## Acknowledgments

- Built on the [iTerm2 Python API](https://iterm2.com/python-api/)
- Inspired by tmux and screen command-line interfaces
- Uses [Click](https://click.palletsprojects.com/) for CLI framework
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "it2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "automation, cli, iterm2, macos, terminal",
    "author": null,
    "author_email": "Your Name <your.email@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/f4/2a/7653fb096a35d697a2de8e983d9ada7fe6bf798a96d4074697a73cb9d71e/it2-0.1.8.tar.gz",
    "platform": null,
    "description": "# it2\n\nA powerful command-line interface for controlling iTerm2 using its Python API.\n\n## Features\n\n- **Session Management**: Send text, execute commands, split panes, manage sessions\n- **Window Control**: Create, move, resize, and manage windows\n- **Tab Operations**: Create and navigate between tabs\n- **Profile Management**: List, create, and apply iTerm2 profiles\n- **Broadcasting**: Send input to multiple sessions simultaneously\n- **Monitoring**: Watch session output, keystrokes, and variables in real-time\n- **Configuration**: Define custom profiles and aliases in YAML\n- **Shortcuts**: Quick access to common commands\n\n## Requirements\n\n- macOS with iTerm2 3.3.0 or later\n- Python 3.8+\n- iTerm2 Python API enabled (Preferences > General > Magic > Enable Python API)\n\n## Installation\n\n### Using pip\n\n```bash\npip install it2\n```\n\n### Using uvx (recommended)\n\n```bash\nuvx it2\n```\n\n## Quick Start\n\n```bash\n# Send text to current session\nit2 send \"Hello, World!\"\n\n# Run a command\nit2 run \"ls -la\"\n\n# Split the current pane vertically\nit2 vsplit\n\n# Create a new window\nit2 new\n\n# List all sessions\nit2 ls\n```\n\n## Basic Usage\n\n### Session Operations\n\n```bash\n# Send text (without newline)\nit2 session send \"text\"\nit2 send \"text\"  # shortcut\n\n# Execute command (with newline)\nit2 session run \"command\"\nit2 run \"command\"  # shortcut\n\n# Target specific session or all sessions\nit2 send \"text\" --session <id>\nit2 send \"text\" --all\n\n# Split panes\nit2 session split          # horizontal split\nit2 session split -v       # vertical split\nit2 vsplit                 # shortcut for vertical split\n\n# Session management\nit2 session list           # list all sessions\nit2 session close          # close current session\nit2 session restart        # restart session\nit2 session clear          # clear screen\n```\n\n### Window Operations\n\n```bash\n# Window management\nit2 window new             # create new window\nit2 window list            # list all windows\nit2 window close           # close current window\nit2 window focus <id>      # focus specific window\n\n# Window manipulation\nit2 window move 100 200    # move to position\nit2 window resize 800 600  # resize window\nit2 window fullscreen on   # enable fullscreen\n\n# Window arrangements\nit2 window arrange save \"dev\"      # save arrangement\nit2 window arrange restore \"dev\"   # restore arrangement\n```\n\n### Tab Operations\n\n```bash\n# Tab management\nit2 tab new                # create new tab\nit2 tab list               # list all tabs\nit2 tab close              # close current tab\nit2 tab select <id>        # select specific tab\n\n# Tab navigation\nit2 tab next               # go to next tab\nit2 tab prev               # go to previous tab\nit2 tab goto 2             # go to tab by index\n```\n\n### Profile Operations\n\n```bash\n# Profile management\nit2 profile list           # list all profiles\nit2 profile show \"Default\" # show profile details\nit2 profile create \"MyProfile\" --base \"Default\"\nit2 profile apply \"MyProfile\"\n\n# Profile configuration\nit2 profile set \"MyProfile\" font-size 14\nit2 profile set \"MyProfile\" bg-color \"#000000\"\nit2 profile set \"MyProfile\" transparency 0.9\n```\n\n### Application Control\n\n```bash\n# App management\nit2 app activate           # bring iTerm2 to front\nit2 app hide               # hide iTerm2\nit2 app theme dark         # set theme\n\n# Broadcasting\nit2 app broadcast on       # enable broadcasting\nit2 app broadcast off      # disable broadcasting\nit2 app broadcast add session1 session2  # create broadcast group\n```\n\n### Monitoring\n\n```bash\n# Monitor output\nit2 monitor output -f                      # follow output\nit2 monitor output -f -p \"ERROR\"           # filter by pattern\n\n# Monitor keystrokes\nit2 monitor keystroke                      # all keystrokes\nit2 monitor keystroke -p \"^[a-z]+$\"        # filter by regex\n\n# Monitor variables\nit2 monitor variable lastCommand           # session variable\nit2 monitor variable buildNumber --app     # app variable\n\n# Monitor prompts (requires shell integration)\nit2 monitor prompt\n```\n\n## Configuration\n\nCreate `~/.it2rc.yaml` to define custom profiles and aliases:\n\n```yaml\n# Custom profiles\nprofiles:\n  dev:\n    - command: cd ~/project\n    - split: vertical\n    - pane1: npm run dev\n    - pane2: npm test --watch\n  \n  servers:\n    - split: 2x2\n    - pane1: ssh server1\n    - pane2: ssh server2\n    - pane3: ssh server3\n    - pane4: ssh server4\n\n# Command aliases\naliases:\n  deploy: session run \"deploy.sh\" --all\n  logs: monitor output -f -p \"ERROR|WARN\"\n  dev-setup: load dev\n```\n\nUse configurations:\n\n```bash\n# Load a profile\nit2 load dev\n\n# Execute an alias\nit2 alias deploy\n\n# Show config path\nit2 config-path\n\n# Reload configuration\nit2 config-reload\n```\n\n## Advanced Examples\n\n### Development Environment Setup\n\n```bash\n# Create a development workspace\nit2 window new --profile \"Development\"\nit2 split\nit2 send \"cd ~/project && npm run dev\"\nit2 session focus 2\nit2 send \"cd ~/project && npm test --watch\"\n```\n\n### Multi-Server Management\n\n```bash\n# SSH to multiple servers with broadcasting\nit2 tab new\nit2 split && it2 split && it2 split\nit2 app broadcast on\nit2 send \"ssh production-server\"\n```\n\n### Automated Deployment\n\nCreate a deployment script:\n\n```bash\n#!/bin/bash\n# deploy.sh\n\n# Create deployment window\nit2 window new --profile \"Deploy\"\n\n# Split for monitoring\nit2 split -v\n\n# Start deployment in first pane\nit2 send \"cd ~/project && ./deploy-prod.sh\"\n\n# Monitor logs in second pane\nit2 session focus 2\nit2 run \"tail -f /var/log/deploy.log\"\n\n# Watch for errors\nit2 monitor output -f -p \"ERROR|FAILED\"\n```\n\n## Environment Variables\n\n- `IT2_DEFAULT_PROFILE`: Default profile name\n- `IT2_CONFIG_PATH`: Path to configuration file (default: `~/.it2rc.yaml`)\n- `IT2_TIMEOUT`: Command timeout in seconds\n\n## Error Codes\n\n- `0`: Success\n- `1`: General error\n- `2`: Connection error (iTerm2 not running or API not enabled)\n- `3`: Target not found (session/window/tab not found)\n- `4`: Invalid arguments\n\n## Development\n\n### Setup Development Environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/mkusaka/it2.git\ncd it2\n\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate\n\n# Install in development mode\npip install -e \".[dev]\"\n\n# Run tests\npytest\n\n# Run linting\nruff check .\nblack --check .\nmypy .\n```\n\n### Project Structure\n\n```\nit2/\n\u251c\u2500\u2500 src/\n\u2502   \u2514\u2500\u2500 it2/\n\u2502       \u251c\u2500\u2500 __init__.py\n\u2502       \u251c\u2500\u2500 cli.py              # Main CLI entry point\n\u2502       \u251c\u2500\u2500 commands/           # Command modules\n\u2502       \u2502   \u251c\u2500\u2500 session.py\n\u2502       \u2502   \u251c\u2500\u2500 window.py\n\u2502       \u2502   \u251c\u2500\u2500 tab.py\n\u2502       \u2502   \u251c\u2500\u2500 profile.py\n\u2502       \u2502   \u251c\u2500\u2500 app.py\n\u2502       \u2502   \u251c\u2500\u2500 monitor.py\n\u2502       \u2502   \u251c\u2500\u2500 shortcuts.py\n\u2502       \u2502   \u2514\u2500\u2500 config_commands.py\n\u2502       \u251c\u2500\u2500 core/               # Core functionality\n\u2502       \u2502   \u251c\u2500\u2500 connection.py\n\u2502       \u2502   \u251c\u2500\u2500 session_handler.py\n\u2502       \u2502   \u2514\u2500\u2500 errors.py\n\u2502       \u2514\u2500\u2500 utils/              # Utilities\n\u2502           \u2514\u2500\u2500 config.py\n\u251c\u2500\u2500 tests/                      # Test files\n\u251c\u2500\u2500 pyproject.toml              # Project configuration\n\u251c\u2500\u2500 README.md                   # This file\n\u2514\u2500\u2500 example.it2rc.yaml          # Example configuration\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n## Acknowledgments\n\n- Built on the [iTerm2 Python API](https://iterm2.com/python-api/)\n- Inspired by tmux and screen command-line interfaces\n- Uses [Click](https://click.palletsprojects.com/) for CLI framework",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 mkusaka\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "A powerful command-line interface for controlling iTerm2",
    "version": "0.1.8",
    "project_urls": {
        "Bug Tracker": "https://github.com/mkusaka/it2/issues",
        "Documentation": "https://github.com/mkusaka/it2#readme",
        "Homepage": "https://github.com/mkusaka/it2",
        "PyPI": "https://pypi.org/project/it2/",
        "Source Code": "https://github.com/mkusaka/it2"
    },
    "split_keywords": [
        "automation",
        " cli",
        " iterm2",
        " macos",
        " terminal"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e4d54eb32a328b5cf7b82d0c6ff61329e9b1389872ebe111b69683f452b783c2",
                "md5": "61eddf39a475be7a98c2017fc37167b5",
                "sha256": "e609cd75cad3b5bcd8ca2e02f7a283a24aa1508de22170adc103456b12f0f1f9"
            },
            "downloads": -1,
            "filename": "it2-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "61eddf39a475be7a98c2017fc37167b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 26128,
            "upload_time": "2025-07-13T16:34:39",
            "upload_time_iso_8601": "2025-07-13T16:34:39.480067Z",
            "url": "https://files.pythonhosted.org/packages/e4/d5/4eb32a328b5cf7b82d0c6ff61329e9b1389872ebe111b69683f452b783c2/it2-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f42a7653fb096a35d697a2de8e983d9ada7fe6bf798a96d4074697a73cb9d71e",
                "md5": "901cd869f3f30ebf3fd2869bff905ac8",
                "sha256": "6266883d2f9b986c88b95e6405509eb54c1e32cfea4098ec7c700433d06118b3"
            },
            "downloads": -1,
            "filename": "it2-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "901cd869f3f30ebf3fd2869bff905ac8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 20607,
            "upload_time": "2025-07-13T16:34:41",
            "upload_time_iso_8601": "2025-07-13T16:34:41.016914Z",
            "url": "https://files.pythonhosted.org/packages/f4/2a/7653fb096a35d697a2de8e983d9ada7fe6bf798a96d4074697a73cb9d71e/it2-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-13 16:34:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mkusaka",
    "github_project": "it2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "it2"
}
        
Elapsed time: 1.24877s