Skip to content

Instantly share code, notes, and snippets.

@telnet2
Created March 10, 2026 03:32
Show Gist options
  • Select an option

  • Save telnet2/e2a6faedb51219659c43895eb7dde711 to your computer and use it in GitHub Desktop.

Select an option

Save telnet2/e2a6faedb51219659c43895eb7dde711 to your computer and use it in GitHub Desktop.
Self-extracting byobu + tmux installer with OSC 52 clipboard support
#!/bin/bash
# Self-extracting byobu + tmux installer with OSC 52 clipboard support
# Usage: curl -sL <gist-raw-url> | bash
set -euo pipefail
BYOBU_CONFIG="$HOME/.byobu"
# --- Install byobu and tmux ---
if ! command -v byobu &>/dev/null || ! command -v tmux &>/dev/null; then
echo "Installing byobu and tmux..."
if command -v apt-get &>/dev/null; then
sudo apt-get update && sudo apt-get install -y byobu tmux
elif command -v yum &>/dev/null; then
sudo yum install -y byobu tmux
elif command -v dnf &>/dev/null; then
sudo dnf install -y byobu tmux
elif command -v pacman &>/dev/null; then
sudo pacman -S --noconfirm byobu tmux
elif command -v brew &>/dev/null; then
brew install byobu tmux
else
echo "Error: No supported package manager found. Install byobu and tmux manually."
exit 1
fi
else
echo "byobu and tmux already installed."
fi
# --- Deploy config ---
echo "Deploying byobu config to $BYOBU_CONFIG ..."
if [ -d "$BYOBU_CONFIG" ] && [ ! -f "$BYOBU_CONFIG/.installed-from-gist" ]; then
backup="$BYOBU_CONFIG.bak.$(date +%Y%m%d%H%M%S)"
echo "Backing up existing config to $backup"
cp -a "$BYOBU_CONFIG" "$backup"
fi
mkdir -p "$BYOBU_CONFIG"
# --- Embedded config files ---
cat > "$BYOBU_CONFIG/.tmux.conf" << 'TMUXCONF'
# Change prefix to Ctrl-k
unbind C-a
set -g prefix C-k
bind C-k send-prefix
# (optional) keep old Ctrl-a as send-prefix escape
bind a send-prefix
# Allow OSC 52 clipboard passthrough to local terminal
set -g allow-passthrough on
TMUXCONF
cat > "$BYOBU_CONFIG/profile.tmux" << 'PROFILETMUX'
# .byobu/profile.tmux
source $BYOBU_PREFIX/share/byobu/profiles/tmux
# scrollback buffer size
set-option -g history-limit 100000
set -g mouse on
set -g base-index 1
set -g default-terminal 'screen-256color'
set -g focus-events on
set -g set-clipboard on
set -g automatic-rename on
bind p paste-buffer
# My key-bindings
bind-key -T prefix C-v display-panes \; split-window -h -c "#{pane_current_path}"
bind-key -T prefix C-h display-panes \; split-window -v -c "#{pane_current_path}"
bind-key -T prefix C-k confirm-before kill-pane
bind-key -T prefix C-[ copy-mode
bind-key -T prefix = select-layout even-horizontal
bind-key -n M-c new-window -c "#{pane_current_path}"
bind-key -n S-Left previous-window
bind-key -n S-Right next-window
bind-key -n S-Up switch-client -p
bind-key -n S-Down switch-client -n
bind-key -n M-q select-pane -t 0
bind-key -n M-1 select-pane -t 0
bind-key -n M-2 select-pane -t 1
bind-key -n M-3 select-pane -t 2
bind-key -n M-0 select-pane -t 3
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
bind-key -n M-Up display-panes \; select-pane -U
bind-key -n M-Down display-panes \; select-pane -D
bind-key -n M-Left display-panes \; select-pane -L
bind-key -n M-Right display-panes \; select-pane -R
bind-key -n M-S-Up resize-pane -U 5
bind-key -n M-S-Down resize-pane -D 5
bind-key -n M-S-Left resize-pane -L 5
bind-key -n M-S-Right resize-pane -R 5
bind-key -n M-S-t run-shell "$BYOBU_PREFIX/lib/byobu/include/tmux-detach-all-but-current-client"
# Double LMB Select & Copy (Word)
bind-key -T copy-mode-vi DoubleClick1Pane \
select-pane \; \
send-keys -X select-word \; \
send-keys -X copy-pipe-and-cancel
bind-key -n DoubleClick1Pane \
select-pane \; \
copy-mode -M \; \
send-keys -X select-word \; \
send-keys -X copy-pipe-and-cancel
# Triple LMB Select & Copy (Line)
bind-key -T copy-mode-vi TripleClick1Pane \
select-pane \; \
send-keys -X select-line \; \
send-keys -X copy-pipe-and-cancel
bind-key -n TripleClick1Pane \
select-pane \; \
copy-mode -M \; \
send-keys -X select-line \; \
send-keys -X copy-pipe-and-cancel
PROFILETMUX
cat > "$BYOBU_CONFIG/keybindings.tmux" << 'KEYTMUX'
set -g prefix F12
unbind-key -n C-a
KEYTMUX
cat > "$BYOBU_CONFIG/keybindings" << 'KEYBINDINGS'
source $BYOBU_PREFIX/share/byobu/keybindings/common
KEYBINDINGS
cat > "$BYOBU_CONFIG/backend" << 'BACKEND'
BYOBU_BACKEND=tmux
BACKEND
cat > "$BYOBU_CONFIG/color" << 'COLOR'
BACKGROUND=k
FOREGROUND=w
MONOCHROME=0
COLOR
cat > "$BYOBU_CONFIG/color.tmux" << 'COLORTMUX'
BYOBU_DARK="\#333333"
BYOBU_LIGHT="\#EEEEEE"
BYOBU_ACCENT="\#75507B"
BYOBU_HIGHLIGHT="\#DD4814"
COLORTMUX
cat > "$BYOBU_CONFIG/datetime.tmux" << 'DATETIME'
BYOBU_DATE="%Y-%m-%d "
BYOBU_TIME="%H:%M:%S"
DATETIME
cat > "$BYOBU_CONFIG/profile" << 'PROFILE'
source $BYOBU_PREFIX/share/byobu/profiles/common
PROFILE
cat > "$BYOBU_CONFIG/original.profile.tmux" << 'ORIGPROFILE'
source $BYOBU_PREFIX/share/byobu/profiles/tmux
ORIGPROFILE
cat > "$BYOBU_CONFIG/prompt" << 'PROMPT'
[ -r /usr/share/byobu/profiles/bashrc ] && . /usr/share/byobu/profiles/bashrc #byobu-prompt#
PROMPT
touch "$BYOBU_CONFIG/.screenrc"
touch "$BYOBU_CONFIG/.welcome-displayed"
touch "$BYOBU_CONFIG/windows"
touch "$BYOBU_CONFIG/windows.tmux"
date > "$BYOBU_CONFIG/.installed-from-gist"
echo ""
echo "Done! Run 'byobu' to start."
echo ""
echo "Key config:"
echo " Prefix: Ctrl-k"
echo " OSC 52: enabled (clipboard over mosh/ssh)"
echo " Mouse: enabled"
echo " Scrollback: 100,000 lines"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment