Skip to main content

tmux session generator

Project description

matemux


matemux is a simple tmux session generator: it generates a session with customized window and pane layouts from a yaml file, called a recipe.

usage

$ matemux [RECIPE-FILE-NAME] [--args] [ARGS]...

create the session based on .matemux/RECIPE-FILE-NAME.yml with ARGS following --args flag. $MATEMUX_DIR is ~/.matemux by default. You could change it by setting $MATEMU_DIR in your environment.

examples

$ matemux example --args --command runserver --port 8000 create a session based on ~/.matemux/example.yml and pass command=runserver and port=8000 to example.yml commands.

recipes

each session is generated from a .yml file called a recipe. a sample recipe is shown below:

~/.matemux/example.yml

---
session: example
root: ~/projects/example
defaults:
  command: runserver
  port: 8000
commands:
  - source activate venv/bin/activate
  - C-l
focus: sql
windows:
  - window: main
    focus: 2
    panes:
        - pane: 0
          commands:
            - htop
        - pane: 1
          commands:
            - neofetch
          next-split-vertical: true
        - pane: 2
          root: ~/projects/example/server
          commands:
            - "{{command}} {{port}}"
  - window: home
    root: ~/

At the top level of a .yml file, the following keys could be defined:

  • session is the name of the session to be created. It accepts strings and integer values.
  • root defines the default directory for all virtual terminals in the session. It must be a valid path. By default, it's set to '~/'.
  • defaults is the default arguments to be passed to commands, we'll cover them later on. they should be an object of key-value pairs. It could be omitted.
  • commands are a list of commands that are executed in all virtual terminals in the session. it could be omitted.
  • focus defines the window to focus on at the initial state of the session. By default, it's the first window. It accepts strings (name of the window) or integers (window number (0, 1, ...))
  • windows is a list of window configuration, with the following keys:
    • window is the name of the window. It could be omitted, in that case, it's set by default to its index.
    • root defines the default directory for all panes in the window. It must be a valid path. By default, it's set to the session's root.
    • focus defines the pane to focus on at the initial state of the window. By default, it's the first pane (index 0)
    • panes is a list of pane configuration, with the following keys:
      • pane it's completely optional and has no effect. It could be set to the pane index to make the .yml file more readable, especially in regards to window focus.
      • root defines the default directory for the pane. It must be a valid path. By default, it's set to the parent window's root.
      • commands are a list of commands to be executed in the pane.
      • next-split-vertical is a boolean that defines whether or not the split for the next pane should be vertical. By default, it's set to false. Imagine the current layout is like this:
       ----------------
       |              |
       |      0       |
       |              |
       |              |
       ----------------
      
      if it's false, when if we define another pane, the new layout would be:
      ----------------
      |       |      |
      |   0   |   1  |
      |       |      |
      |       |      |
      ----------------
      
      but if it's true, the new layout would be:
      ----------------
      |      0       |
      |______________|
      |      1       |
      |              |
      ----------------
      

running $ matemux example creates a session with two windows: first window is called main and has the following layout:

---------------
|      |   1  |
|  0   |______|
|      |   2  |
|      |      |
---------------

htop is running in pane 0, neofetch is running in pane 1, and runserver 8000 is running in in pane 2. second window is called home and has a single pane.

Notes about commands and defaults:

  • commands are propagated: If you set some commands for a session, some commands for a window, and some commands for a pane, they're all executed in the pane's virtual terminal, in that order.

  • You could use custom arguments in commands, in the form {{arg}} and pass the arguments through commandline. For example, if you have a command mysql -u {{user}} you could pass user like this: $ matemux example --args --user myuser if you want a default value for user, you should set it in session's defaults like:

    defaults:
      user: myuser
  • It's important to note argument names should only contain characters from the English alphabet and they're case-sensitive.

Author

Kamyab Taghizadeh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matemux-0.1.3.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

matemux-0.1.3-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file matemux-0.1.3.tar.gz.

File metadata

  • Download URL: matemux-0.1.3.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.13.5-arch1-1

File hashes

Hashes for matemux-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ddc078a221f717f85e9803b7795e1e52981663fe8b63e2c2ee7a027483d1be5a
MD5 10a1df4aaa62e91d71613eca0d2502e7
BLAKE2b-256 38f9f1279beb2c2a488a5fe3a2ff4d9745fc1beed608bab0f84a736c69ad2c41

See more details on using hashes here.

File details

Details for the file matemux-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: matemux-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.13.5-arch1-1

File hashes

Hashes for matemux-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0631e92a62d6192c728ed65332bb4fd522b80129608e7e2a9f4d0a0f29fcd65d
MD5 4df76daa45a800cb048cf1de0c7acc16
BLAKE2b-256 e4312496a0f08909d5a3fb25c2f9ca3c2f3d8b2f280e8c79375275e656062e22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page