From 809b84029d102db1e82b8cc30ed5f15542982f3b Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sun, 25 Aug 2019 23:19:49 -0400 Subject: [PATCH] tmux: reorg and cleanup tmux.conf Tmux is becoming a daily driver these days, so I thought I'd show the rc file a little attention. Besides just a cleanup to split iinto settings/bindings/theme, some notable changes are: - removed `setw mode-keys vi`, because tmux is smart enough to get that from $EDITOR - fixed "reloaded" command, needed '\;' - removed commented out bit about electron on macOS. Not using it these days! --- tmux/tmux.conf | 65 ++++++++++++++++++++++++++--------------------------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/tmux/tmux.conf b/tmux/tmux.conf index edb06b4..227c18a 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -1,23 +1,38 @@ +#----------# +# Settings # +#----------# +set -g prefix C-a # Who can reach C-b? +set -g mouse on # I guess mice are useful sometimes.. +set -g base-index 1 # Start windows at 1 +set -g pane-base-index 1 # Start panes at 1 +set -g renumber-windows on # Closed windows renumber +set -s escape-time 0 # ESC instantly passed through to process +set -g set-clipboard off # Use xclip over escape-code-clipboard #1119 + +# Set default term based on $TERM +set default-terminal screen # More support for "screen" than "tmux" +if "bash -c '[[ $TERM =~ 256color ]]'" 'set default-terminal screen-256color' + + +#----------# +# Bindings # +#----------# + # remap prefix from 'C-b' to 'C-a' unbind C-b -set-option -g prefix C-a bind C-a send-prefix # split panes using | and - -bind | split-window -h -c "#{pane_current_path}" -bind - split-window -v -c "#{pane_current_path}" unbind '"' unbind % - -# Set the default terminal in a smart fashion -set default-terminal screen # More support for "screen" than "tmux" -if "bash -c '[[ $TERM =~ 256color ]]'" 'set default-terminal screen-256color' +bind | split-window -h -c "#{pane_current_path}" +bind - split-window -v -c "#{pane_current_path}" # new window same directory bind c new-window -c "#{pane_current_path}" -# reload config file (change file location to your the tmux.conf you want to use) -bind r source-file ~/.tmux.conf; display "reloaded" +# reload config file +bind r source-file ~/.tmux.conf \; display 'reloaded' # switch panes using vim keys bind C-h select-pane -L @@ -26,38 +41,14 @@ bind C-k select-pane -U bind C-l select-pane -R # set vi-bindings for scrolling -set-window-option -g mode-keys vi bind -T copy-mode-vi v send -X begin-selection bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard' -# st can't handle a large clipboard. Setting clipboard off causes the above -# pipe to xclip to take precedence: -# https://github.com/tmux/tmux/issues/1119 -set -g set-clipboard off - -# Set mouse on for scrolling / pane selection and resizing -set -g mouse on - -# set window and pane numbering to start at 1 -set -g base-index 1 -set -g pane-base-index 1 - -# set windows to renumber themselves when closed -set -g renumber-windows on - -# remove delay w escape key -set -s escape-time 0 - -# stop other apps from renaming windows -set allow-rename off - -# Patch for apps such as electron in tmux on osx -# set-option -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL" - -# GoToHttp +# GoToHttp -- find the last url in the buffer bind H copy-mode\; send -X search-backward "http" \; send -X begin-selection \; send -X next-space-end bind -T copy-mode-vi H send -X start-of-line \; send -X search-again \; send -X begin-selection \; send -X next-space-end + #-------# # THEME # #-------# @@ -72,12 +63,8 @@ set -g window-status-current-style "fg=brightwhite,bg=blue" # Status set -g status-style "fg=white,bg=black" set -g status-interval 60 - -# Status Left set -g status-left-length 20 set -g status-left-style "fg=black,bg=yellow" - -# Status Right set -g status-right "[$USER@#h] #(slstatus -s)" set -g status-right-length 90 set -g status-right-style "fg=black,bg=magenta" -- libgit2 0.28.4