Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
218 lines (168 sloc) 7.54 KB
# Tmux config file
conf_dir="$HOME/.config/tmux"
# set-option, -g for global, -a to append to existing option.
# Enable mouse selection and option toggling.
set-window-option -g mouse on
# Enable vi for copy-mode.
set-window-option -g mode-keys vi
set-window-option -g xterm-keys on
# Set clipboard using OSC 52 ANSI escapes
set-window-option -g set-clipboard on
# Increase history because memory is cheap.
set-option -g history-limit 100000
# How long to display messages for in milliseconds.
set-option -g display-time 1500
# Address vim mode switching delay (http://superuser.com/a/252717/65504)
set-option -s escape-time 0
# Focus events enabled for terminals that support them.
set-option -g focus-events on
# Use C-t as the prefix because it's less useful than C-b.
unbind C-b
set-option -g prefix C-t
# Start windows numbering at 1.
set-option -g base-index 1
# Start pane numbering at 1.
set-window-option -g pane-base-index 1
# Re-number windows when a window is closed.
set-option -g renumber-windows on
# Update status line every 5 seconds (default 15).
set-option -g status-interval 5
# Enable 24 bit color.
set-option -g default-terminal "xterm-24bit"
# Enable 24 bit color support.
# https://github.com/syl20bnr/spacemacs/wiki/Terminal
set-option -g -a terminal-overrides ',xterm-24bit:Tc'
set-option -g default-shell /bin/zsh
set-option -g default-command "${SHELL}"
bind-key R run-shell ' \
tmux source-file ~/.tmux.conf > /dev/null; \
tmux display-message "Reloaded .tmux.conf."'
# NOTE: tmux runs commands with 'sh', so the command must be POSIX compliant.
# That means no ZSH functions, use executables on PATH instead.
if-shell '[ "$(uname -s)" = "Darwin" ]' 'source-file ~/.config/tmux/osx.conf'
bind-key -T root C-y run-shell "tmux-smart-paste"
# Copy / Paste
bind-key C-t copy-mode
# `send-keys -X` sends a command into copy mode.
bind-key -T copy-mode-vi 'C-g' send-keys -X cancel
bind-key P paste-buffer
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
bind-key -T copy-mode-vi 'C-v' send-keys -X rectangle-toggle
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel "clipboard-copy"
bind-key -T copy-mode-vi 'C-y' send-keys -X copy-selection
bind-key -T copy-mode-vi 'p' send-keys -X paste-buffer
bind-key -T copy-mode-vi 'H' send-keys -X start-of-line
bind-key -T copy-mode-vi 'L' send-keys -X end-of-line
bind-key -T copy-mode-vi 'J' send-keys -X -N 5 cursor-down
bind-key -T copy-mode-vi 'K' send-keys -X -N 5 cursor-up
bind-key -T copy-mode-vi 'C-j' send-keys -X page-down
bind-key -T copy-mode-vi 'C-k' send-keys -X page-up
bind-key -T copy-mode-vi 'Y' send-keys -X copy-end-of-line
bind-key -T copy-mode-vi 'C-r' send-keys -X search-backward-incremental
bind-key -T copy-mode-vi 'C-s' send-keys -X search-forward-incremental
bind-key -T copy-mode-vi 'c' send-keys -X copy-pipe-and-cancel "tmux-copy-with-osc-52" \; display-message "Copied to clipboard."
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "clipboard-copy" \; display-message "Copied to clipboard."
bind-key + delete-buffer
set-hook -g pane-focus-in 'run-shell tmux-on-pane-focus-in'
# new-session -d -n ranger -s dev ranger
# new-window -d
# Window and pane management
# Special tokens for windows
# Token Meaning
# {start} ^ The lowest-numbered window
# {end} $ The highest-numbered window
# {last} ! The last (previously current) window
# {next} + The next window by number
# {previous} - The previous window by number
# Select windows.
bind-key -T root -r C-M-l next-window
bind-key -T root -r C-M-h previous-window
# Kill the current window.
bind-key x kill-window
bind-key c new-window -c "#{pane_current_path}"
bind-key / split-window -h -c "#{pane_current_path}"
bind-key - split-window -v -c "#{pane_current_path}"
# Special tokens for panes
# {last} ! The last (previously active) pane
# {next} + The next pane by number
# {previous} - The previous pane by number
# {top} The top pane
# {bottom} The bottom pane
# {left} The leftmost pane
# {right} The rightmost pane
# {top-left} The top-left pane
# {top-right} The top-right pane
# {bottom-left} The bottom-left pane
# {bottom-right} The bottom-right pane
# {up-of} The pane above the active pane
# {down-of} The pane below the active pane
# {left-of} The pane to the left of the active pane
# {right-of} The pane to the right of the active pane
# Select panes with vi movement commands.
bind-key -T root -r M-h select-pane -L
bind-key -T root -r M-j select-pane -D
bind-key -T root -r M-k select-pane -U
bind-key -T root -r M-l select-pane -R
# Move panes around within a window and follow the moving pane.
bind-key -T root -r M-H swap-pane -t {left-of} \; select-pane -t {left-of}
bind-key -T root -r M-J swap-pane -t {down-of} \; select-pane -t {down-of}
bind-key -T root -r M-K swap-pane -t {up-of} \; select-pane -t {up-of}
bind-key -T root -r M-L swap-pane -t {right-of} \; select-pane -t {right-of}
# Move current pane into a new window in the specified direction.
bind-key -T root M-Left break-pane \; select-window -t {last}
bind-key -T root M-Right break-pane \; select-window -t {last} \; \
move-window -r -t {last}
# Pull one pane from the specified direction into current window. Reverses the
# command above.
bind-key -T root M-S-Left join-pane -s :{previous}
bind-key -T root M-S-Right join-pane -s :{next}
# Pull a pane into current window as a new pane.
bind-key @ command-prompt -p "create pane from:" "join-pane -s ':%%'"
# Small pane resizes.
bind-key -T root C-Left resize-pane -L 2
bind-key -T root C-Down resize-pane -D 2
bind-key -T root C-Up resize-pane -U 2
bind-key -T root C-Right resize-pane -R 2
# Large pane resizes.
bind-key -T root C-S-Up resize-pane -U 8
bind-key -T root C-S-Down resize-pane -D 8
bind-key -T root C-S-Left resize-pane -L 8
bind-key -T root C-S-Right resize-pane -R 8
# Kill panes with a dedicated key.
bind-key -T root -r C-M-k kill-pane
# Layouts
bind-key -T root M-Up next-layout
bind-key -T root M-Down previous-layout
# FZF commands
bind-key -T prefix F run-shell "zsh -c \
'iosource-list-file-paths-from-tmux-pane #{pane_id} \
| fzf-tmux -- --reverse --multi \
| join-input-by-space'"
# Status bar
set-option -g status-left-length 32
set-option -g status-right-length 150
set-option -g status-left '#[fg=white][#S] '
set-option -g window-status-format " #I:#W "
set-window-option -g window-status-current-format "#[bg=#00533A] #I:#W#{?window_zoomed_flag, (zoom),} "
set-option -g status-right ''
# Colors
set-option -g status-fg white
set-option -g status-bg '#18191b'
set-option -g window-status-activity-attr bold
# Use default background so it doesn't get overridden to black
# set-option -g window-style 'bg=#00171d'
# set-option -g window-active-style 'bg=colour0'
set-option -g pane-border-fg colour245
set-option -g pane-active-border-fg blue
set-option -g message-fg yellow
set-option -g message-bg '#18191b'
set-option -g @prefix_highlight_show_copy_mode 'on'
# List of plugins
set-option -g @plugin 'tmux-plugins/tpm'
set-option -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set-option -g @plugin 'tmux-plugins/tmux-open'
set-option -g @prefix_highlight_bg 'blue'
set-option -g @prefix_highlight_show_copy_mode 'on'
set-option -g @prefix_highlight_copy_mode_attr 'fg=black,bg=yellow,bold'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'