Skip to main content

key2pane

Tests

Sends a sequence of keys to any tmux pane, based on the pane's current command.

Contents

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:

{
  // 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:

pip install key2pane

which panel will install the key2pane command.

Usage

Expanding on the example in the introduction, consider the following configuration:

{
  // 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:

{
  "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

Contributing

Contributions are welcome! Please see CONTRIBUTING for more information.

License

Distributed under the MIT License.

Metadata

Release files for key2pane 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for key2pane 0.0.1
File Size Uploaded Provenance Actions
key2pane-0.0.1.tar.gz 14.4 kB Without provenance Details for key2pane-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for key2pane 0.0.1
File Interpreter ABI Platform Actions
key2pane-0.0.1-py3-none-any.whl Python 3 none any Details for key2pane-0.0.1-py3-none-any.whl

Total release size: 24.4 kB

Release files / key2pane-0.0.1.tar.gz

Download URL key2pane-0.0.1.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0fb526f33ac5536b3f4d63f78f34bc2dfef3b35688527c66be076b36713f7adf
BLAKE2b-256 checksum
How to use checksums
01b8e7c401f9831d7d818b261d1bfc2fa84ff7b2bbffe4df25eb4c3358b25cf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / key2pane-0.0.1-py3-none-any.whl

Download URL key2pane-0.0.1-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3100c2babaf61008b2c1e5f80ec5bb51da0a8f45a2de8208f2c574867405664c
BLAKE2b-256 checksum
How to use checksums
b232e05684e600d9574eac4a1cd56c0c90646b47f98e5585713cda5ad08a4118
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Security for key2pane 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page