wemux - Multi-User Terminals

Back to SIG Tooling & Set Up Tutorials

[WeMux](https://github.com/zolrath/wemux) enables a shared [TMUX](https://github.com/tmux/tmux) session, so multiple developers can collaborate within the same terminal. This can be useful for pair programming, or co-piloting on a deployment.

Setup

NOTE: This will only work on a remote machine that you have `sudo` access to.

# Download WeMux
curl -sLO https://github.com/zolrath/wemux/archive/refs/tags/v3.2.0.zip

# Unzip it
unzip v3.2.0

# Move it (requires sudo)
sudo mv wemux-v3.2.0 /usr/local/share/wemux

# Symlink to bin dir (requires sudo)
sudo ln -s /usr/local/share/wemux/wemux /usr/local/bin/wemux

# Copy Default Config
sudo cp /usr/local/share/wemux/wemux.conf.example /usr/local/etc/wemux.conf

# Edit the wemux.conf
sudo sed -i '' "s/## example: host_groups.*/host_groups('wheel')/" /usr/local/etc/wemux.conf

Running a wemux session

To start a wemux session, use: `wemux start`.

To detach from a session, use `crtl+b d`. You can reattach by using `wemux attach`.

To stop the session, detach and use `wemux stop`.

Vim-like TMUX Configuration

Copy the code below to `~/.tmux.conf` to provide fun VIM-esque keybindings for tmux/wemux.

Note: This will change the prefix from `b` to `s` (e.g. `ctrl+s d` to detach).

New Tabs/Panes:

- `ctrl+s c` - create a new tab

- `ctrl+s |` - split the current tab into two vertical panes

- `ctrl+s -` - split the current tab into two horizontal panes

Navigation commands:

- `ctrl+s h` - select left pane

- `ctrl+s j` - select bottom pane

- `ctrl+s k` - select top pane

- `ctrl+s l` - select right pane

- `ctrl+s ctrl+h` - rotate to next tab to the left

- `ctrl+s ctrl+l` - rotate to next tab to the right

Resizing commands:

- `ctrl+s H` - Make current pane 5 columns larger to the left

- `ctrl+s J` - Make current pane 5 rows larger on the bottom

- `ctrl+s K` - Make current pane 5 rows larger on the top

- `ctrl+s L` - Make current pane 5 columns larger to the right

Configuration (`~/.tmux/conf`)

# improve colors
set -g default-terminal 'screen-256color'

# act like vim
setw -g mode-keys vi
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+

set -g prefix2 C-s

# start window numbers at 1 to match keyboard order with tmux window order
set -g base-index 1
set-window-option -g pane-base-index 1

# renumber windows sequentially after closing any of them
set -g renumber-windows on

# soften status bar color from harsh green to light gray
set -g status-style bg='#666666',fg='#aaaaaa'

# remove administrative debris (session name, hostname, time) in status bar
set -g status-left ''
set -g status-right ''

# increase scrollback lines
set -g history-limit 10000

# prefix -> back-one-character
bind-key C-b send-prefix
# prefix-2 -> forward-incremental-history-search
bind-key C-s send-prefix -2

# don't suspend-client
unbind-key C-z

# Make prefix easier to access
set -g prefix C-a
bind C-a send-prefix

# Make previous prefix usable
unbind C-b

# Make sending keys much more responsive
set -s escape-time 1

# Reload tmux config for all sessions
bind r source-file ~/.tmux.conf

# Bind | to split panes horizontal
bind | split-window -h

# Bind - to split panes horizontal
bind - split-window -v

# Resize panes
bind H resize-pane -L 5
bind J resize-pane -D 5
bind K resize-pane -U 5
bind L resize-pane -R 5