{"id":20047038,"url":"https://github.com/bartste/tmux-key2pane","last_synced_at":"2026-02-11T02:08:38.701Z","repository":{"id":231284603,"uuid":"781304246","full_name":"BartSte/tmux-key2pane","owner":"BartSte","description":"Send commands to any tmux pane.","archived":false,"fork":false,"pushed_at":"2025-01-05T16:34:46.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-08T11:28:45.215Z","etag":null,"topics":["bash","command-line","command-line-tool","fish","linux","neovim","python3","tmux","vim","zsh"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BartSte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-03T06:07:21.000Z","updated_at":"2025-01-05T16:34:50.000Z","dependencies_parsed_at":"2025-05-27T00:48:42.270Z","dependency_job_id":null,"html_url":"https://github.com/BartSte/tmux-key2pane","commit_stats":null,"previous_names":["bartste/key2pane","bartste/tmux-key2pane"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/BartSte/tmux-key2pane","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BartSte%2Ftmux-key2pane","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BartSte%2Ftmux-key2pane/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BartSte%2Ftmux-key2pane/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BartSte%2Ftmux-key2pane/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BartSte","download_url":"https://codeload.github.com/BartSte/tmux-key2pane/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BartSte%2Ftmux-key2pane/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29325513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T00:34:26.354Z","status":"online","status_checked_at":"2026-02-11T02:00:08.436Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","command-line","command-line-tool","fish","linux","neovim","python3","tmux","vim","zsh"],"created_at":"2024-11-13T11:33:09.441Z","updated_at":"2026-02-11T02:08:38.687Z","avatar_url":"https://github.com/BartSte.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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## TODO:\n\n- When running `key2pane` from the cli, it treats the current pane as `python`\n  instead of the shell. This may be expected, but is confusing for the user.\n- When enabling --reset from the cli nothing happens. When enabling it from the\n  config file, it results in a KeyboardInterrupt.\n\n## Contents\n\n\u003c!--toc:start--\u003e\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\u003c!--toc:end--\u003e\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 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\nNote that the following may occur, which is expected behavior but may cause some\nconfusion:\n\nYou run the following command from window 0, pane 0:\n\n```sh\nkey2pane -w 0 -p 0 foo bar\n```\n\nThe command is executed and send to the same tmux pane. Which is fine, but you\nmight the following output:\n\n```sh\nERROR:root:No action found for command python3\n```\n\nThis is expected behavior because during the execution of the `key2pane` command\nthe command is `python3`, and not your shell anymore. If you want the command of\nthe pane to remain the shell, you can use:\n\n```sh\nkey2pane -w 0 -p 0 --reset foo bar \u0026\n```\n\nwhich will execute the command in a subshell, and thus not changing the command\nof 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartste%2Ftmux-key2pane","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbartste%2Ftmux-key2pane","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartste%2Ftmux-key2pane/lists"}