Skip to content

Instantly share code, notes, and snippets.

@aculich
Last active April 13, 2024 14:22
Show Gist options
  • Save aculich/6bf1b43f56a10b85352eb8b1f544937b to your computer and use it in GitHub Desktop.
Save aculich/6bf1b43f56a10b85352eb8b1f544937b to your computer and use it in GitHub Desktop.
# To automatically start tmux on a remote system
# add this to the ~/.ssh/config Host stanzas
# Host remote-with-tmux
# RequestTTY yes
# RemoteCommand tmux new -A
# see also: https://github.com/tmux/tmux/wiki/Clipboard
# and also: https://blog.jbowen.dev/tips/ssh-tmux/
# and also: https://www.freecodecamp.org/news/tmux-in-practice-integration-with-system-clipboard-bcd72c62ff7b/
# propagate titles to the window
set -g set-titles on
# Minimalist window title "0:bash"
set -g set-titles-string "#I:#W"
# show colors
set -g default-terminal "screen-256color"
# rename window to current process
set-window-option -g automatic-rename on
# this enables mouse selections and scroll wheel
set -g mouse on
set -s set-clipboard on
set -g mode-keys vi
# Update all bindings to integrate copy-buffer with macOS.
# brew install reattach-to-user-namespace
unbind-key -T copy-mode M-w
bind-key -T copy-mode C-w send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode Enter send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X stop-selection
# Copy on select in tmux
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'
# Paste in tmux
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbpaste'
# I keep dragging when just selecting the window.
unbind-key -T root MouseDrag1Pane
# Double clicking selects the word also when not in copy-mode.
bind-key -T root DoubleClick1Pane select-pane \; copy-mode \; send-keys -X select-word
# Start new window on Ctrl-n. Mapped to Command-n in .alacritty.yml
# This matches the behaviour of the Terminal app for starting new windows.
bind-key -T root C-n new-window
# C-o both cleans the screen and history. Mapped to Command-k in .alacritty.yml
# This matches the behaviour of Terminal app to quickly clear all.
bind-key -T root C-o send-keys C-l \; run-shell "sleep .3s" \; clear-history
# Ctrl-Left/Right to cycle the windows
bind-key -T root C-Left previous-window
bind-key -T root C-Right next-window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment