# C-b already in use by vim for page up. Use screen's prefix. set -g prefix C-a unbind C-b bind C-a send-prefix # Make ^a a send ^a (Useful in minicom) bind a send-prefix # No delay for escape key press (vim mode changes) set -sg escape-time 0 # Copy mode more intuitive for vim users, use v and y # From https://dev.to/iggredible/the-easy-way-to-copy-text-in-tmux-319g # See https://ianthehenry.com/posts/how-to-configure-tmux/ for copy-pipe tips. bind -T copy-mode-vi v send -X begin-selection bind -T copy-mode-vi C-v send -X rectangle-toggle bind -T copy-mode-vi y send -X copy-selection-and-cancel # Vim style pane splitting bind v split-window -h bind s split-window -v # Vim style pane selection bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R # pane sizing with capital letters bind -r H resize-pane -L bind -r J resize-pane -D bind -r K resize-pane -U bind -r L resize-pane -R # Use Alt-vim keys without prefix key to switch panes bind -n M-h select-pane -L bind -n M-j select-pane -D bind -n M-k select-pane -U bind -n M-l select-pane -R # These next two bind-key f and o are from: https://jyn.dev/how-i-use-my-terminal/ # 1. Do a `rg` search. # 2. Prefix + f to enter copy mode and search backward for a file path regex. # 3. Once found, Prefix + o to open the file in $EDITOR. bind-key f copy-mode \; send-keys -X search-backward \ '(^|\<|[[:space:]/])(("(~/|/)?[[:alnum:] _\.#$%&+=@-]+(/[[:alnum:] _\.#$%&+=@-]+)*"|(~/|/)?[[:alnum:]_\.#$%&+=@-]+(/[[:alnum:]_\.#$%&+=@-]+)*[[:alnum:]_\.#$%&+=@-]+):[0-9]{1,10}(:[0-9]{1,10})?)|~?/[[:alnum:]_\.#$%&+=@-]+(/[[:alnum:]_\.#$%&+=@-]+)+|[[:alnum:]_\.#$%&+=@-]+(/[[:alnum:]_\.#$%&+=@-]+){2,}' # save the buffer, then open an editor in the current pane bind-key -T copy-mode-vi o send-keys -X copy-pipe-and-cancel \ 'xargs -I {} tmux send-keys "${EDITOR:-vi} {}"; tmux send-keys "C-m"' # open an app in current directory in a popup # from https://www.youtube.com/watch?v=70cN9swORE8&t=440s #bind o popup -E -d "#{pane_current_path}" -w 90% -h 90% "opencode" # https://www.reddit.com/r/tmux/comments/olgte7/comment/jz4t9rc/ # Toggle scratch session. # Create a detached session and disable the status line before attaching to it bind b if -F '#{==:#{session_name},scratch}' { detach-client } { if "tmux has-session -t scratch" { popup -E -w 90% "tmux attach -t scratch" } { popup -E -w 90% "tmux new -d -c '#{pane_current_path}' -s scratch && \ tmux set -t scratch status off && \ tmux attach -t scratch" } } # (Removed) Use Alt-arrow keys without prefix key to switch panes # Note vim's Copilot plugin uses M-Right for "accept suggested word" #bind -n M-Right select-pane -R # Use prefix-! to break-pane a pane into a new window. # Use these to join another pane to this window (choosing which pane). bind-key S choose-window 'join-pane -v -s "%%"' bind-key V choose-window 'join-pane -h -s "%%"' # Use Tab to rotate full-screen panes like I do vim buffers bind -r Tab select-pane -t .+1 \; resize-pane -Z # Theme set -g status-keys vi set -g status-fg white set -g focus-events on set -g status-bg colour235 set -g status-left-length 10 set -g status-left "#[fg=green]#{?#{!=:#{window_panes},1},pane #P/#{window_panes},}#[default]" set -g status-justify centre set -g status-right '#[fg=green]%m/%d %H:%M#[default]' setw -g mode-keys vi setw -g automatic-rename on setw -g aggressive-resize # For mouse wheel scrolling, but now have to hold shift when selecting text. set -g mouse on set -g set-titles on set -g set-titles-string "tmux / #T" #set -g allow-rename on ## ssh'ed servers may rename window to PS1, duplicating path #setw -g window-status-current-format '#[fg=yellow]#I:#F:#T:.../#{b:pane_current_path}#[default]' setw -g window-status-current-format '#{?#{!=:#{session_windows},1},#I:#W:,}#[fg=yellow]#{?window_zoomed_flag,Z:,}#{s\/home/dblume\~\:pane_current_path}#[default]' setw -g window-status-format '#[fg=colour241]#I:#W#[default]' # This allows neovim's hi htmlItalic (also used by markdown) to use italic font # See https://wiki.dlma.com/apple#tmux-and-tmux-256color for macOS installation set -g default-terminal "tmux-256color" # prefix, C-Arrow doesn't work from PuTTY. Needs TERM to be xterm set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@"