Skip to content

tmuxp

Tmuxp is a session manager for tmux, allowing you to define tmux sessions using a YAML configuration

install

sudo apt install tmux
pip install tmuxp

config

my_session.yaml
session_name: my_session
windows:
  - window_name: my_window
    layout: tiled
    suppress_history: false
    shell_command_before:
      - echo "before"
    panes:
      - shell_command: 
          - printf '\033]2;%s\033\\' 'pane1'
          - ./script1.sh  # Runs script1 in the first pane
        focus: true
      - shell_command:
          - printf '\033]2;%s\033\\' 'pane2'
          - ./script2.sh  # Runs script2 in the second pane

usage

tmuxp load my_session.yaml

tmux

script

Open screen with 4 panes

#!/bin/bash

SESSION="mysession"

# Start a new session
tmux new-session -d -s $SESSION

# Split the window into four equal parts
tmux split-window -h  # Split vertically
tmux split-window -v  # Split bottom-left horizontally
tmux select-pane -R   # Move to the right pane
tmux split-window -v  # Split bottom-right horizontally

# Attach to session
tmux attach-session -t $SESSION

don't forget to chmod +x

Config

tmux.conf
# unbind
unbind C-b
unbind '"'
unbind %

# base1 numbering
set -g base-index 1
setw -g pane-base-index 1

#bind ctrl-a as a prefix
set-option -g prefix C-a
bind-key C-a send-prefix
# kill session
bind C-c kill-session

bind C-a run "tmux save-buffer - | xclip -i -sel clipboard"

# mouse
set -g mouse on


 # do like terminator
bind -n C-E split-window -h
bind -n C-S-Left resize-pane -L 3
bind -n C-S-Right resize-pane -R 3
bind -n C-S-Up resize-pane -U 3
bind -n C-S-Down resize-pane -D 3
bind -n C-O split-window -v

# switch panes using Alt-arrow without prefix (not working)
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Shift arrow to switch windows

bind n next-window
bind p previous-window

bind c new-window -c "#{pane_current_path}"

bind r source-file ~/.tmux.conf

# settings