Skip to content
willfishPublic

About

Fast, dependency-free tmuxinator replacement for tmux and Herdr

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

mux

A small tmuxinator replacement for tmux, the Herdr TUI, and the Herdr desktop app, written in C.

Backends: tmux + Herdr + Herdr app Language: C

mux demo

Why

tmuxinator requires Ruby. mux is a single binary that launches the same tmuxinator-style project files into tmux sessions, Herdr TUI workspaces, or Herdr desktop spaces.

Size comparison

Tool Install size
mux 64 KB
tmuxinator 85 MB

That's ~1300x smaller. The tmuxinator closure includes Ruby, RubyGems, and all gem dependencies. mux just needs libyaml and libc.

Multiplexer backends

One config. Three backends. mux turns tmuxinator-compatible YAML into repeatable terminal workspaces:

  • tmux - the default backend, with full tmuxinator-style session support
  • herdr - workspaces, tabs, and panes in the older Herdr terminal app
  • herdr-app - spaces, tabs, and panes in the Herdr desktop app, powered by hc
mux start work              # tmux backend
mux start --backend herdr work
mux start --backend herdr-app work
MUX_BACKEND=herdr-app mux start work

The desktop app and the older TUI use different runtimes. Select herdr-app for the desktop app; herdr does not control it. Backend selection uses --backend first, then MUX_BACKEND, then tmux.

Install

Quick install (Linux/macOS)

curl -fsSL https://raw.githubusercontent.com/willfish/mux/master/install.sh | sh

This downloads a pre-built binary for your platform. Supports:

  • Linux x86_64 / aarch64
  • macOS aarch64 (Apple Silicon)

Intel Mac users: build from source (see below).

Nix flake

Add mux as a flake input and include it in your packages via an overlay:

# flake.nix
{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    mux = {
      url = "github:willfish/mux";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, home-manager, mux, ... }:
    let
      system = "x86_64-linux";
      overlay = final: prev: {
        mux = mux.packages.${system}.default;
      };
      pkgs = import nixpkgs {
        inherit system;
        overlays = [ overlay ];
      };
    in {
      homeConfigurations.yourname = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;
        modules = [ ./home ];
      };
    };
}

Then add mux to your Home Manager packages:

# home/packages.nix
{ pkgs, ... }:
{
  home.packages = with pkgs; [
    mux
  ];
}

nix profile

nix profile install github:willfish/mux

From source

Requires: C11 compiler, meson, ninja, libyaml

meson setup build
meson compile -C build
meson install -C build

Development

nix develop
meson setup builddir
meson compile -C builddir
meson test -C builddir

Usage

mux start <project>       Start a tmux session or Herdr space/workspace
mux stop <project>        Stop a tmux session or Herdr space/workspace
mux new <project>         Create a new project config
mux edit <project>        Edit a project config in $EDITOR
mux copy <src> <dst>      Copy a project config
mux delete <project>      Delete a project config
mux list                  List available projects
mux debug <project>       Print generated backend script
mux local                 Start from ./.tmuxinator.yml
mux doctor                Check dependencies
mux completions <shell>   Print shell completion script (bash/zsh/fish)

Shortcuts

mux <project>             Same as mux start <project>
mux s                     start
mux e, open, o            edit
mux cp                    copy
mux rm                    delete
mux ls, l                 list

Flags

-n, --name NAME           Override session name
-p, --project-config P    Specify config file path
-b, --backend NAME        Backend to use: tmux, herdr, or herdr-app
-a, --append              Add windows to existing tmux session
-A, --active              Only list active sessions
    --attach              Force attach on start
    --no-attach           Start detached
    --no-pre-window       Skip project pre_window commands
    --local               Create ./.tmuxinator.yml (for new)

Flags may be passed before or after the project name, for example mux start work --backend tmux.

Template variables

Configs can use <%= @settings["key"] %> (or single-quoted @settings['key']), <%= @args[0] %>, and <%= ENV["VAR"] %> placeholders, filled from CLI args and environment variables:

mux start myproject host=localhost port=3000 main

Configuration

mux reads tmuxinator-compatible YAML configs from:

  1. $TMUXINATOR_CONFIG/
  2. $XDG_CONFIG_HOME/tmuxinator/
  3. ~/.config/tmuxinator/
  4. ~/.tmuxinator/
  5. ./.tmuxinator.yml (local, via mux local)

Example config

name: myproject
root: ~/code/myproject

on_project_start: echo "Starting myproject"

windows:
  - editor:
      layout: main-vertical
      panes:
        - vim
        - guard
  - server: bundle exec rails s
  - logs: tail -f log/development.log

Herdr desktop backend

Open the Herdr desktop app, then run:

mux start --backend herdr-app work

To make it your default, set MUX_BACKEND=herdr-app in your shell environment (Fish: set -gx MUX_BACKEND herdr-app). Then mux start work loads the same work.yml without an extra flag. No separate desktop template is needed.

The desktop backend maps a project to one local space, windows to named tabs, and panes to splits. It sends pane commands through hc to the new terminals' shells. Project and window roots, pre-commands, lifecycle hooks, and startup tab/pane selection are supported. Without a root, terminals start in the directory where you run mux.

A repeat start selects the existing local space with the project's name and does not send its pane commands again. Remote spaces with the same name are left alone. If multiple local spaces have that name, mux fails rather than selecting or closing an arbitrary space. mux stop work closes the matching local space and ends its terminals when this backend is selected.

Requirements and limits:

  • herdr-app, hc, and python3 must be on PATH, with a Herdr app window open. mux does not open the app or start the older Herdr server.
  • Layout strings select right/down splits, not exact tmux geometry or ratios. The desktop CLI does not support custom pane titles or pane synchronization.
  • tmux sockets, tmux command overrides, and append mode have no desktop equivalent.
  • list --active, doctor, and stop-all remain tmux-specific commands.
  • on_project_exit runs when mux returns, not when the desktop app closes.

MUX_HERDR_APP_COMMAND and MUX_HC_COMMAND can override the executable paths. They take one executable each, not shell command strings.

Older Herdr TUI backend

mux launches tmuxinator layouts into tmux by default, and can launch the same layouts into Herdr workspaces:

mux start --backend herdr work
MUX_BACKEND=herdr mux start work

The Herdr backend starts the Herdr server when needed, maps one tmuxinator project to one Herdr workspace, maps tmuxinator windows to Herdr tabs, and maps panes to Herdr pane splits. Pane names are applied with herdr pane rename, and pane commands are sent to the pane shell just like the tmux backend sends keys to tmux panes.

tmux remains the fallback unless --backend or MUX_BACKEND selects another backend. Known limitations:

  • python3 is required at runtime to parse Herdr's JSON CLI output.
  • tmux layout: strings are approximated with Herdr split directions and ratios; Herdr does not currently replay tmux layout strings directly.
  • tmux-specific options such as sockets, tmux command overrides, and tmux pane synchronization do not have Herdr equivalents.

Compatibility

mux aims for full compatibility with tmuxinator YAML configs. Your existing configs should work unchanged.

Supported features:

  • All window/pane layouts
  • Project hooks (on_project_start, on_project_stop, etc.)
  • pre_window commands
  • Window-specific root directories
  • Pane synchronisation
  • Pane titles
  • Socket name/path
  • Custom tmux command
  • Deprecated field aliases (project_name, project_root, tabs, cli_args)

Shell completions

# bash: add to ~/.bashrc
eval "$(mux completions bash)"

# zsh: add to ~/.zshrc
eval "$(mux completions zsh)"

# fish: add to ~/.config/fish/config.fish
mux completions fish | source

License

MIT

About

Fast, dependency-free tmuxinator replacement for tmux and Herdr

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages