Last active
October 11, 2024 06:46
-
-
Save jwpleow/ed40a91e8909ea3dc2bd7b37096b38e8 to your computer and use it in GitHub Desktop.
Setting up tmux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # INSTALLATION | |
| # sudo apt install tmux xsel && git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm | |
| # Install plugins with Ctrl+b + I (capitalised!!) | |
| # select text via mouse by holding shift first - if having issues with selection going to another pane, use prefix + z to zoom/unzoom on the current panel | |
| # Prefix default = Ctrl + b (C-b) | |
| # Copy Pasting using copy mode: | |
| # enter copy mode - C-b [, start copying with C-space, and press y to copy with tmux-yank | |
| # Search in copy mode -> Search down - C-s | Search up - C-r | |
| #Useful shortcuts | |
| # C-b r (reload tmux conf, set below) | |
| # Panes | |
| # C-b . (Split panes vertically) | |
| # C-b / (Split panes horizontally) | |
| # C-b x (Kill current pane) | |
| # C-b Alt-5 (Organise panes to 4 equal tiles) | |
| # Windows | |
| # C-b c (create new tmux window) | |
| # C-b n (go to next tmux window) | |
| # C-b 1 ...9 (go to window number n) | |
| # C-b & (kill the current window) | |
| # Sessions | |
| # tmux new -s <sessionname> (create a new named session) | |
| # C-b s (choose a session) | |
| # C-b d (detach from current session) | |
| # C-s Pause printouts | |
| # C-q Resume printouts | |
| ###################################################################### | |
| # START OF PLUGINS | |
| ###################################################################### | |
| set -g @plugin 'tmux-plugins/tpm' | |
| set -g @plugin 'tmux-plugins/tmux-sensible' | |
| # resurrect saved session on restart | |
| # set -g @plugin 'tmux-plugins/tmux-resurrect' | |
| # save tmux buffer to system clipboard (hold shift key for mouseover selection) | |
| set -g @plugin 'tmux-plugins/tmux-yank' | |
| # continuous saving of session | |
| # set -g @plugin 'tmux-plugins/tmux-continuum' | |
| ####################################################### | |
| # TMUX-CONTINUUM | |
| ####################################################### | |
| # Enables restoral of saved tmux config | |
| set -g @continuum-restore 'on' | |
| # How often to save a tmux layout | |
| set -g @continuum-save-interval '1' | |
| ####################################################### | |
| # TMUX-RESURRECT | |
| ####################################################### | |
| # Capture contents of each pane | |
| set -g @resurrect-capture-pane-contents 'on' | |
| # Restore window size after resurrect | |
| set -g @resurrect-hook-post-save-all 'eval $(xdotool getwindowgeometry --shell $WINDOWID); echo 0,$X,$Y,$WIDTH,$HEIGHT > $HOME/.tmux/resurrect/geometry' | |
| set -g @resurrect-hook-pre-restore-all 'wmctrl -i -r $WINDOWID -e $(cat $HOME/.tmux/resurrect/geometry)' | |
| ####################################################### | |
| # TMUX-SENSIBLE | |
| ####################################################### | |
| # Increase scrollback buffer size | |
| set -g history-limit 10000 | |
| # upgrade $TERM | |
| set -g default-terminal "screen-256color" | |
| # super useful when using "grouped sessions" and multi-monitor setup | |
| setw -g aggressive-resize on | |
| ####################################################### | |
| # TMUX-YANK | |
| ####################################################### | |
| set -g @yank_with_mouse on | |
| set -g @yank_action 'copy-pipe' | |
| ###################################################################### | |
| # END OF PLUGINS | |
| ###################################################################### | |
| ####################################################### | |
| # KEY BINDINGS | |
| ####################################################### | |
| # split panes using prefix and . and / instead | |
| bind . split-window -v | |
| bind / split-window -h | |
| unbind '"' | |
| unbind % | |
| # switch panes using Alt-arrow without prefix | |
| 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 | |
| # Quick reload tmux config | |
| bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded" | |
| ###################################################################### | |
| # START OF GENERAL CONFIGURATIONS | |
| ###################################################################### | |
| # Enable mouse mode (tmux 2.1 and above) | |
| set -g mouse on | |
| # Use default shell | |
| set-option -g default-shell $SHELL | |
| ###################### | |
| ### DESIGN CHANGES ### | |
| ###################### | |
| # panes | |
| set -g pane-border-style 'fg=colour19 bg=colour0' | |
| set -g pane-active-border-style 'bg=colour0 fg=colour9' | |
| # statusbar | |
| set -g status-position bottom | |
| set -g status-justify left | |
| set -g status-style 'bg=colour18 fg=colour137 dim' | |
| set -g status-right '#{?client_prefix,#[reverse]<Prefix>#[noreverse] ,}"#{=21:pane_title}" #[fg=colour233,bg=colour19] %d/%m #[fg=colour233,bg=colour8] %H:%M:%S ' | |
| set -g status-right-length 50 | |
| set -g status-left-length 20 | |
| setw -g window-status-current-style 'fg=colour1 bg=colour19 bold' | |
| setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F ' | |
| setw -g window-status-style 'fg=colour9 bg=colour18' | |
| setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' | |
| #setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold' | |
| # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) | |
| run '~/.tmux/plugins/tpm/tpm' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment