# key2pane
[![Tests](https://github.com/BartSte/tmux-key2pane/actions/workflows/test.yml/badge.svg)](https://github.com/BartSte/tmux-key2pane/actions/workflows/test.yml)
Sends a sequence of keys to any tmux pane, based on the pane's current command.
## Contents
<!--toc:start-->
- [Contents](#contents)
- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)
<!--toc:end-->
## Introduction
`key2pane` is a tmux plugin for sending a sequence of keys to a tmux pane, based
on the target pane's command that is running. Which keys are sent can be
configured in a json file:
```json
{
// Other settings ...
"actions": [
{
"regex": "bash|zsh|fish",
"keys": ["echo 'Hello, World!'", "Enter"]
}
]
}
```
When the command of the target pane matches the regex, the keys are sent to the
pane. In this case, the command: `echo 'Hello, World!'` is sent to the pane, and
then the `Enter` key is sent.
** TODO: Add a demo gif here **
## Installation
Install `key2pane` using pip:
```sh
pip install key2pane
```
which panel will install the `key2pane` command.
## Usage
Expanding on the example in the [introduction](#introduction), consider the
following configuration:
```json
{
// Other settings ...
"session": "test",
"window": 0,
"index": 0,
"actions": [
{
"regex": "bash|zsh|fish",
"keys": ["echo '{0} {1}'", "Enter"]
}
]
}
```
When we run the `key2pane foo bar` command, the following will happen:
- For the session `test`, window `0`, and pane `0`, the command is retrieved.
- If this command matches the regex `bash|zsh|fish`, the keys `echo '{0} {1}'`
are selected.
- The placeholders `{0}` and `{1}` are replaced with the positional arguments
`foo` and `bar`.
- The formatted keys are send to the pane, using `tmux send-keys`. After that,
the `Enter` key is sent.
- As a result, the command `echo 'foo bar'` is executed in the pane.
## Configuration
When you run the `key2pane` command for the first time, no configuration file
is exists yet. You need to create a configuration file in the default location
`~/.config/key2pane/config.json`, or specify a different location using the
`--config` option. As a starting point, you can use the following example:
```json
{
"session": null,
"window": null,
"index": null,
"reset": false,
"logfile": null,
"loglevel": null,
"actions": [
{
"regex": "bash|zsh|fish",
"keys": ["echo '{0}'", "Enter"]
},
{
"regex": "python[0-9]*",
"keys": ["print('{0}')", "Enter"]
}
]
}
```
Since comments are not allowed in JSON, notes are placed here:
- **session**: the session name. Default: current session.
- **window**: the window index. Default: current window.
- **index**: the pane index. Default: current pane.
- **reset**: send a Ctrl-C before sending the keys. Default: false
- **logfile**: the log file. Default: ~/.local/state/key2pane/key2pane.log
- **loglevel**: the log level. Default: WARNING
- **actions**: a list of actions, containing a `regex`, and a `keys` property.
The `keys` are send to the target pane when the `regex` matches the command
of the target pane.
## Troubleshooting
If you encounter any issues, please report them on the issue tracker at:
[tmux-key2pane issues](https://github.com/BartSte/tmux-key2pane/issues)
## Contributing
Contributions are welcome! Please see [CONTRIBUTING](./CONTRIBUTING.md) for
more information.
## License
Distributed under the [MIT License](./LICENCE).
Raw data
{
"_id": null,
"home_page": null,
"name": "key2pane",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "tmux, key, send, pane, keys, send-keys, send-keys-to-pane, send-keys-to-pane",
"author": "BartSte",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/01/b8/e7c401f9831d7d818b261d1bfc2fa84ff7b2bbffe4df25eb4c3358b25cf5/key2pane-0.0.1.tar.gz",
"platform": null,
"description": "# key2pane\n\n[![Tests](https://github.com/BartSte/tmux-key2pane/actions/workflows/test.yml/badge.svg)](https://github.com/BartSte/tmux-key2pane/actions/workflows/test.yml)\n\nSends a sequence of keys to any tmux pane, based on the pane's current command.\n\n## Contents\n\n<!--toc:start-->\n\n- [Contents](#contents)\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Configuration](#configuration)\n- [Troubleshooting](#troubleshooting)\n- [Contributing](#contributing)\n- [License](#license)\n\n<!--toc:end-->\n\n## Introduction\n\n`key2pane` is a tmux plugin for sending a sequence of keys to a tmux pane, based\non the target pane's command that is running. Which keys are sent can be\nconfigured in a json file:\n\n```json\n{\n // Other settings ...\n\n \"actions\": [\n {\n \"regex\": \"bash|zsh|fish\",\n \"keys\": [\"echo 'Hello, World!'\", \"Enter\"]\n }\n ]\n}\n```\n\nWhen the command of the target pane matches the regex, the keys are sent to the\npane. In this case, the command: `echo 'Hello, World!'` is sent to the pane, and\nthen the `Enter` key is sent.\n\n** TODO: Add a demo gif here **\n\n## Installation\n\nInstall `key2pane` using pip:\n\n```sh\npip install key2pane\n```\n\nwhich panel will install the `key2pane` command.\n\n## Usage\n\nExpanding on the example in the [introduction](#introduction), consider the\nfollowing configuration:\n\n```json\n{\n // Other settings ...\n\n \"session\": \"test\",\n \"window\": 0,\n \"index\": 0,\n \"actions\": [\n {\n \"regex\": \"bash|zsh|fish\",\n \"keys\": [\"echo '{0} {1}'\", \"Enter\"]\n }\n ]\n}\n```\n\nWhen we run the `key2pane foo bar` command, the following will happen:\n\n- For the session `test`, window `0`, and pane `0`, the command is retrieved.\n- If this command matches the regex `bash|zsh|fish`, the keys `echo '{0} {1}'`\n are selected.\n- The placeholders `{0}` and `{1}` are replaced with the positional arguments\n `foo` and `bar`.\n- The formatted keys are send to the pane, using `tmux send-keys`. After that,\n the `Enter` key is sent.\n- As a result, the command `echo 'foo bar'` is executed in the pane.\n\n## Configuration\n\nWhen you run the `key2pane` command for the first time, no configuration file\nis exists yet. You need to create a configuration file in the default location\n`~/.config/key2pane/config.json`, or specify a different location using the\n`--config` option. As a starting point, you can use the following example:\n\n```json\n{\n \"session\": null,\n \"window\": null,\n \"index\": null,\n \"reset\": false,\n \"logfile\": null,\n \"loglevel\": null,\n \"actions\": [\n {\n \"regex\": \"bash|zsh|fish\",\n \"keys\": [\"echo '{0}'\", \"Enter\"]\n },\n {\n \"regex\": \"python[0-9]*\",\n \"keys\": [\"print('{0}')\", \"Enter\"]\n }\n ]\n}\n```\n\nSince comments are not allowed in JSON, notes are placed here:\n\n- **session**: the session name. Default: current session.\n- **window**: the window index. Default: current window.\n- **index**: the pane index. Default: current pane.\n- **reset**: send a Ctrl-C before sending the keys. Default: false\n- **logfile**: the log file. Default: ~/.local/state/key2pane/key2pane.log\n- **loglevel**: the log level. Default: WARNING\n- **actions**: a list of actions, containing a `regex`, and a `keys` property.\n The `keys` are send to the target pane when the `regex` matches the command\n of the target pane.\n\n## Troubleshooting\n\nIf you encounter any issues, please report them on the issue tracker at:\n[tmux-key2pane issues](https://github.com/BartSte/tmux-key2pane/issues)\n\n## Contributing\n\nContributions are welcome! Please see [CONTRIBUTING](./CONTRIBUTING.md) for\nmore information.\n\n## License\n\nDistributed under the [MIT License](./LICENCE).\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Send keys to any tmux pane",
"version": "0.0.1",
"project_urls": null,
"split_keywords": [
"tmux",
" key",
" send",
" pane",
" keys",
" send-keys",
" send-keys-to-pane",
" send-keys-to-pane"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b232e05684e600d9574eac4a1cd56c0c90646b47f98e5585713cda5ad08a4118",
"md5": "a534f1afc989c5a4d6cc4355b5a41041",
"sha256": "3100c2babaf61008b2c1e5f80ec5bb51da0a8f45a2de8208f2c574867405664c"
},
"downloads": -1,
"filename": "key2pane-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a534f1afc989c5a4d6cc4355b5a41041",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 10037,
"upload_time": "2024-04-07T08:44:02",
"upload_time_iso_8601": "2024-04-07T08:44:02.315032Z",
"url": "https://files.pythonhosted.org/packages/b2/32/e05684e600d9574eac4a1cd56c0c90646b47f98e5585713cda5ad08a4118/key2pane-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "01b8e7c401f9831d7d818b261d1bfc2fa84ff7b2bbffe4df25eb4c3358b25cf5",
"md5": "92c59e240de2df4a25816bd793b6f924",
"sha256": "0fb526f33ac5536b3f4d63f78f34bc2dfef3b35688527c66be076b36713f7adf"
},
"downloads": -1,
"filename": "key2pane-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "92c59e240de2df4a25816bd793b6f924",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 14391,
"upload_time": "2024-04-07T08:44:03",
"upload_time_iso_8601": "2024-04-07T08:44:03.863639Z",
"url": "https://files.pythonhosted.org/packages/01/b8/e7c401f9831d7d818b261d1bfc2fa84ff7b2bbffe4df25eb4c3358b25cf5/key2pane-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-07 08:44:03",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "key2pane"
}