Skip to content

Instantly share code, notes, and snippets.

@xirixiz
Last active September 27, 2024 06:15
Show Gist options
  • Save xirixiz/54326e9ef522d899bf20444764aeacf1 to your computer and use it in GitHub Desktop.
Save xirixiz/54326e9ef522d899bf20444764aeacf1 to your computer and use it in GitHub Desktop.
simple tmux.conf file with shortcut explanation(s)
# Change the prefix from 'C-b' to '`' (backtick)
unbind C-b
set -g prefix '`'
bind '`' send-prefix
# Window and pane index start at 1
set -g base-index 1
set -g pane-base-index 1
# Refresh interval for status bar every 60 seconds
set -g status-interval 60
# Proxy environment variables
set-option -ga update-environment 'http_proxy https_proxy all_proxy no_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY NO_PROXY'
# Pane splitting in the current path
bind '\' split-window -h -c "#{pane_current_path}"
bind '=' split-window -v -c "#{pane_current_path}"
# Quick command bindings
# bind q send-keys "sudo su -" Enter
# Disable automatic renaming of windows
set-window-option -g automatic-rename off
# Window navigation bindings
bind p previous-window
bind n next-window
# Pane navigation with Shift + Arrow keys
bind-key -n S-Up select-pane -U
bind-key -n S-Down select-pane -D
bind-key -n S-Left select-pane -L
bind-key -n S-Right select-pane -R
# Copy mode and mouse controls
bind b copy-mode
bind m set-option -g mouse \; display-message 'Mouse mode is now #{?mouse,on,off}!'
bind s set-window-option synchronize-panes \; display-message "Synchronized panes are now #{?pane_synchronized,on,off}"
# Open new windows in the current pane path
bind c new-window -c "#{pane_current_path}"
# Open/select windows with keys 0-9
bind-key 0 if-shell 'tmux select-window -t :0' '' 'new-window -t :0 -c "#{pane_current_path}"'
bind-key 1 if-shell 'tmux select-window -t :1' '' 'new-window -t :1 -c "#{pane_current_path}"'
bind-key 2 if-shell 'tmux select-window -t :2' '' 'new-window -t :2 -c "#{pane_current_path}"'
bind-key 3 if-shell 'tmux select-window -t :3' '' 'new-window -t :3 -c "#{pane_current_path}"'
bind-key 4 if-shell 'tmux select-window -t :4' '' 'new-window -t :4 -c "#{pane_current_path}"'
bind-key 5 if-shell 'tmux select-window -t :5' '' 'new-window -t :5 -c "#{pane_current_path}"'
bind-key 6 if-shell 'tmux select-window -t :6' '' 'new-window -t :6 -c "#{pane_current_path}"'
bind-key 7 if-shell 'tmux select-window -t :7' '' 'new-window -t :7 -c "#{pane_current_path}"'
bind-key 8 if-shell 'tmux select-window -t :8' '' 'new-window -t :8 -c "#{pane_current_path}"'
bind-key 9 if-shell 'tmux select-window -t :9' '' 'new-window -t :9 -c "#{pane_current_path}"'
# Window selection (or creation if not exists) with keys 0-9
#foreach i in {0..9} {
# bind-key $i if-shell "tmux select-window -t :$i" "" "new-window -t :$i -c '#{pane_current_path}'"
#}
# Reload tmux configuration
bind r source-file ~/.tmux.conf \; display "Reloaded tmux.conf!"
# Shorten escape time delay
set -sg escape-time 1
# Rename and renumber windows options
set -g allow-rename off
set -g renumber-windows on
# Increase scrollback history
set -g history-limit 100000
# Mouse and vi-mode options
set -g mouse off
set-window-option -g mode-keys vi
# Terminal mode and colors
set -g default-terminal "screen-256color"
# Capture visible pane content and display URLs with urlview
bind u capture-pane \; save-buffer /tmp/tmux-buffer \; split-window -l 10 "urlview /tmp/tmux-buffer"
# Unbind default split keys
unbind '"'
unbind %
######################
### DESIGN CHANGES ###
######################
# Bell and activity settings
set -g visual-activity off
set -g visual-bell off
set -g visual-silence off
setw -g monitor-activity off
set -g bell-action none
# Mode and pane border styles
setw -g clock-mode-colour colour15
setw -g mode-style 'fg=colour15 bg=colour236'
set -g pane-border-style 'fg=colour236 bg=colour0'
set -g pane-active-border-style 'fg=colour166 bg=colour166'
# Status bar configuration
set -g status-position bottom
set -g status-justify left
set -g status-style 'fg=colour15 bg=colour236'
set -g status-left ''
set -g status-right '#[fg=colour15,bg=colour236] %A %d/%m/%Y %H:%M:%S '
set -g status-right-length 50
set -g status-left-length 20
# Window status styles
setw -g window-status-current-style 'fg=colour236 bg=colour15'
setw -g window-status-current-format ' X#I '
setw -g window-status-style 'fg=colour15 bg=colour236'
setw -g window-status-format ' #I '
setw -g window-status-bell-style 'fg=colour15 bg=colour236'
# Message style
set -g message-style 'fg=colour236 bg=colour15'
@xirixiz
Copy link
Author

xirixiz commented Sep 27, 2024

image

Tmux Shortcut Summary:

Prefix Key:

  • Changed from C-b (default) to ` (backtick).
  • Hitting backtick twice it prints the backtick

Pane Splitting:

  • Horizontal split: \ (same directory as current pane).
  • Vertical split: = (same directory as current pane).

Window Management:

  • Window Selection (or creation if not exists):
  • 0: Select or create window 0.
  • 1: Select or create window 1.
  • 2: Select or create window 2.
  • 3: Select or create window 3.
  • 4: Select or create window 4.
  • 5: Select or create window 5.
  • 6: Select or create window 6.
  • 7: Select or create window 7.
  • 8: Select or create window 8.
  • 9: Select or create window 9.
  • Next Window: n
  • Previous Window: p
  • New Window: c (in current directory)

Pane Navigation (using Shift + Arrow keys):

  • Up: Shift + Up
  • Down: Shift + Down
  • Left: Shift + Left
  • Right: Shift + Right

Quick Commands:

  • q: Send keys sudo su - + Enter.

Other Functionality:

  • Enter Copy Mode: b
  • Toggle Mouse Mode: m
  • Toggle Pane Synchronization: s
  • Reload Tmux Config: r (reload .tmux.conf)

URL Viewer:

  • u: Capture visible pane, save buffer to file, and open urlview.

Unbound Keys:

  • ", %: Default split keys are unbound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment