iterm2-focus


Nameiterm2-focus JSON
Version 0.0.10 PyPI version JSON
download
home_pageNone
SummaryFocus iTerm2 sessions by ID
upload_time2025-07-12 16:16:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords cli focus iterm2 macos terminal
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # iterm2-focus

Focus iTerm2 sessions by ID from the command line.

## Features

- Focus any iTerm2 session by its ID
- Get the current session ID
- List all available sessions
- Focus the current session (useful when returning from other applications)

## Installation

```bash
pip install iterm2-focus
```

Or using [uv](https://github.com/astral-sh/uv):

```bash
uv pip install iterm2-focus
```

## Quick Usage (without installation)

You can run `iterm2-focus` directly without installing using `uvx`:

```bash
# List all sessions
uvx iterm2-focus --list

# Focus a specific session
uvx iterm2-focus <session-id>

# Get current session ID
uvx iterm2-focus --get-current
```

## Prerequisites

1. **macOS** with iTerm2 installed
2. **Python 3.8** or later
3. **iTerm2 Python API** must be enabled:
   - Open iTerm2
   - Go to *Settings* → *General* → *Magic*
   - Check "Enable Python API"
   - Restart iTerm2

## Usage

### Focus a specific session

```bash
iterm2-focus w0t0p0:12345678-1234-1234-1234-123456789012
```

### Focus the current session

Useful when returning from another application:

```bash
iterm2-focus --current
# or
iterm2-focus -c
```

### Get the current session ID

```bash
iterm2-focus --get-current
# or
iterm2-focus -g
```

### List all sessions

```bash
iterm2-focus --list
# or
iterm2-focus -l
```

### Additional options

```bash
# Show version
iterm2-focus --version

# Quiet mode (suppress output)
iterm2-focus -q <session-id>

# Help
iterm2-focus --help
```

## Examples

### Save and restore focus

```bash
# Save current session ID
SAVED_SESSION=$(iterm2-focus -g -q)

# ... do other work ...

# Return to saved session
iterm2-focus $SAVED_SESSION
```

### Focus a session from another application

```applescript
-- AppleScript example
do shell script "iterm2-focus w0t0p0:12345678-1234-1234-1234-123456789012"
```

## Development

### Setup

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

# Create virtual environment with uv
uv venv
uv pip install -e ".[dev]"
```

### Testing

```bash
# Run tests
uv run pytest

# Run tests with coverage
uv run pytest --cov=iterm2_focus

# Type checking
uv run mypy src

# Linting and formatting
uv run ruff check src tests
uv run black src tests
```

### Building

```bash
# Build the package
uv build

# Upload to PyPI
uv publish
```

## License

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

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Troubleshooting

### "Failed to connect to iTerm2" error

Make sure iTerm2's Python API is enabled (see Prerequisites).

### "Session not found" error

Verify the session ID using `iterm2-focus --list` to see all available sessions.

### Permission errors

On first run, macOS may ask for permission to control iTerm2. Please allow this in System Preferences.

## Author

mkusaka <hinoshita1992@gmail.com>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "iterm2-focus",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "cli, focus, iterm2, macos, terminal",
    "author": null,
    "author_email": "mkusaka <hinoshita1992@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/32/1d/15c8e8ce6e7ccec9474007d404ad920e2d764df463419a0507cf9a9321af/iterm2_focus-0.0.10.tar.gz",
    "platform": null,
    "description": "# iterm2-focus\n\nFocus iTerm2 sessions by ID from the command line.\n\n## Features\n\n- Focus any iTerm2 session by its ID\n- Get the current session ID\n- List all available sessions\n- Focus the current session (useful when returning from other applications)\n\n## Installation\n\n```bash\npip install iterm2-focus\n```\n\nOr using [uv](https://github.com/astral-sh/uv):\n\n```bash\nuv pip install iterm2-focus\n```\n\n## Quick Usage (without installation)\n\nYou can run `iterm2-focus` directly without installing using `uvx`:\n\n```bash\n# List all sessions\nuvx iterm2-focus --list\n\n# Focus a specific session\nuvx iterm2-focus <session-id>\n\n# Get current session ID\nuvx iterm2-focus --get-current\n```\n\n## Prerequisites\n\n1. **macOS** with iTerm2 installed\n2. **Python 3.8** or later\n3. **iTerm2 Python API** must be enabled:\n   - Open iTerm2\n   - Go to *Settings* \u2192 *General* \u2192 *Magic*\n   - Check \"Enable Python API\"\n   - Restart iTerm2\n\n## Usage\n\n### Focus a specific session\n\n```bash\niterm2-focus w0t0p0:12345678-1234-1234-1234-123456789012\n```\n\n### Focus the current session\n\nUseful when returning from another application:\n\n```bash\niterm2-focus --current\n# or\niterm2-focus -c\n```\n\n### Get the current session ID\n\n```bash\niterm2-focus --get-current\n# or\niterm2-focus -g\n```\n\n### List all sessions\n\n```bash\niterm2-focus --list\n# or\niterm2-focus -l\n```\n\n### Additional options\n\n```bash\n# Show version\niterm2-focus --version\n\n# Quiet mode (suppress output)\niterm2-focus -q <session-id>\n\n# Help\niterm2-focus --help\n```\n\n## Examples\n\n### Save and restore focus\n\n```bash\n# Save current session ID\nSAVED_SESSION=$(iterm2-focus -g -q)\n\n# ... do other work ...\n\n# Return to saved session\niterm2-focus $SAVED_SESSION\n```\n\n### Focus a session from another application\n\n```applescript\n-- AppleScript example\ndo shell script \"iterm2-focus w0t0p0:12345678-1234-1234-1234-123456789012\"\n```\n\n## Development\n\n### Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/mkusaka/iterm2-focus\ncd iterm2-focus\n\n# Create virtual environment with uv\nuv venv\nuv pip install -e \".[dev]\"\n```\n\n### Testing\n\n```bash\n# Run tests\nuv run pytest\n\n# Run tests with coverage\nuv run pytest --cov=iterm2_focus\n\n# Type checking\nuv run mypy src\n\n# Linting and formatting\nuv run ruff check src tests\nuv run black src tests\n```\n\n### Building\n\n```bash\n# Build the package\nuv build\n\n# Upload to PyPI\nuv publish\n```\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Troubleshooting\n\n### \"Failed to connect to iTerm2\" error\n\nMake sure iTerm2's Python API is enabled (see Prerequisites).\n\n### \"Session not found\" error\n\nVerify the session ID using `iterm2-focus --list` to see all available sessions.\n\n### Permission errors\n\nOn first run, macOS may ask for permission to control iTerm2. Please allow this in System Preferences.\n\n## Author\n\nmkusaka <hinoshita1992@gmail.com>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Focus iTerm2 sessions by ID",
    "version": "0.0.10",
    "project_urls": {
        "Bug Tracker": "https://github.com/mkusaka/iterm2-focus/issues",
        "Documentation": "https://github.com/mkusaka/iterm2-focus#readme",
        "Homepage": "https://github.com/mkusaka/iterm2-focus",
        "Source Code": "https://github.com/mkusaka/iterm2-focus"
    },
    "split_keywords": [
        "cli",
        " focus",
        " iterm2",
        " macos",
        " terminal"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9cef66a694e426776866246abef6c1ac5ac3499abd81d46d0bf052cbff0ee474",
                "md5": "c4d31e60eeae2787e42401f046b52639",
                "sha256": "1cc8bc77be94ed3c40090bc1b5a7c97492e0cc3c7325ef90788afb862ba5e28e"
            },
            "downloads": -1,
            "filename": "iterm2_focus-0.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c4d31e60eeae2787e42401f046b52639",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8004,
            "upload_time": "2025-07-12T16:16:20",
            "upload_time_iso_8601": "2025-07-12T16:16:20.739095Z",
            "url": "https://files.pythonhosted.org/packages/9c/ef/66a694e426776866246abef6c1ac5ac3499abd81d46d0bf052cbff0ee474/iterm2_focus-0.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "321d15c8e8ce6e7ccec9474007d404ad920e2d764df463419a0507cf9a9321af",
                "md5": "e8c28ebfe1c2fe8d5ecc1d36825d92e1",
                "sha256": "37c9aa3ec54405bd2f9b6ce3a0123ead336eada3d62180e3d388e191fc4eba47"
            },
            "downloads": -1,
            "filename": "iterm2_focus-0.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "e8c28ebfe1c2fe8d5ecc1d36825d92e1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 75770,
            "upload_time": "2025-07-12T16:16:21",
            "upload_time_iso_8601": "2025-07-12T16:16:21.798025Z",
            "url": "https://files.pythonhosted.org/packages/32/1d/15c8e8ce6e7ccec9474007d404ad920e2d764df463419a0507cf9a9321af/iterm2_focus-0.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-12 16:16:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mkusaka",
    "github_project": "iterm2-focus",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "iterm2-focus"
}
        
Elapsed time: 0.49500s