Skip to content

Instantly share code, notes, and snippets.

@Muminur
Created February 15, 2026 10:46
Show Gist options
  • Select an option

  • Save Muminur/bcb3d3c2ebb502c45b1409da107c26ab to your computer and use it in GitHub Desktop.

Select an option

Save Muminur/bcb3d3c2ebb502c45b1409da107c26ab to your computer and use it in GitHub Desktop.
One-liner tmux-yank setup for Ubuntu — copies tmux text to system clipboard (Ctrl+V in browser)
#!/usr/bin/env bash
# tmux-yank one-liner setup for Ubuntu
# Installs TPM + tmux-yank + xclip, configures clipboard yanking
# Usage: bash <(curl -sL https://gist.githubusercontent.com/YOUR_USER/RAW_URL/tmux-yank-setup.sh)
# After running: reload tmux with `tmux source-file ~/.tmux.conf` then `prefix + I` to install plugins
#
# Copy modes:
# Mouse: select text with drag → press y → Ctrl+V in browser
# Keyboard: prefix+[ → Space to start → select → y to yank → Ctrl+V in browser
set -euo pipefail
# Install xclip if missing
command -v xclip >/dev/null 2>&1 || command -v xsel >/dev/null 2>&1 || { echo "Installing xclip..."; sudo apt-get install -y xclip; }
# Install TPM if missing
[ -d ~/.tmux/plugins/tpm ] || { echo "Installing TPM..."; git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm; }
# Write tmux.conf (backs up existing)
[ -f ~/.tmux.conf ] && cp ~/.tmux.conf ~/.tmux.conf.bak.$(date +%s)
cat > ~/.tmux.conf <<'EOF'
# TPM must be listed first
set -g @plugin "tmux-plugins/tpm"
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin "tmux-plugins/tmux-resurrect"
set -g @plugin "tmux-plugins/tmux-continuum"
# Vi copy mode + mouse
setw -g mode-keys vi
set -g mouse on
# Both keyboard and mouse yank go to system clipboard
set -g @yank_selection 'clipboard'
set -g @yank_selection_mouse 'clipboard'
# Continuum auto-restore
set -g @continuum-restore "on"
run "~/.tmux/plugins/tpm/tpm"
EOF
# Install plugins non-interactively
~/.tmux/plugins/tpm/bin/install_plugins
# Reload tmux if running inside a session
[ -n "${TMUX:-}" ] && tmux source-file ~/.tmux.conf && echo "tmux config reloaded!"
echo "Done! If inside tmux, press prefix+I to finalize. Then select text + y to copy to clipboard."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment