1
0
mirror of https://github.com/samoshkin/tmux-config.git synced 2026-01-03 00:08:01 +00:00
Files
tmux-config/tmux/tmux.conf
Alexey Samoshkin 943be96ca9 Initial commit
2017-11-19 00:36:38 +02:00

196 lines
6.0 KiB
Bash

# ==========================
# === General settings ===
# ==========================
set -g history-limit 20000
set -g buffer-limit 20
set -sg escape-time 1
set -g display-time 2000
set -g allow-rename off
set -g default-terminal "screen"
set -g remain-on-exit off
# Change prefix key to C-a, easier to type, same to "screen"
unbind C-b
set -g prefix C-a
# Set parent terminal title to reflect current window in tmux session
set -g set-titles on
set -g set-titles-string "#I:#W"
# Start index of window/pane with 1, because we're humans, not computers
set -g base-index 1
setw -g pane-base-index 1
# Enable mouse support
set -g mouse on
# ==========================
# === Key bindings ===
# ==========================
# Reload tmux configuration
bind C-r source-file ~/.tmux.conf \; display "Reloaded"
# Rename session and window
unbind "\$"
unbind ,
bind r command-prompt -I "#{window_name}" "rename-window '%%'"
bind R command-prompt -I "#{session_name}" "rename-session '%%'"
# Split panes
unbind %
unbind '"'
bind | split-window -h
bind _ split-window -v
# Select windows
unbind }
unbind {
unbind "'"
unbind n
unbind p
unbind l
unbind M-n
unbind M-p
bind -r < previous-window
bind -r > next-window
bind -r M-< previous-window -a # prev window with alert
bind -r M-> next-window -a # next window with alert
bind -r Tab last-window # cycle thru MRU tabs
bind W command-prompt -p "go to window #" "select-window -t ':%%'"
# Link window
bind L command-prompt -p "Link window from (session:window): " "link-window -s %% -a"
# Swap panes back and forth with 1st pane
# When in main-(horizontal|vertical) layouts, the biggest/widest panel is always @1
bind \ if '[ #{pane_index} -eq 1 ]' \
'swap-pane -s "!"' \
'select-pane -t:.1 ; swap-pane -d -t 1 -s "!"'
# select/swap panes (counter)clockwise
bind -r o select-pane -t :.+
bind -r O select-pane -t :.-
bind -r C-o swap-pane -D
# Kill pane/window/session shortcuts
unbind &
bind x kill-pane
bind C-x confirm-before -p "kill-window #W? (y/n)" kill-window
bind X confirm-before -p "kill-session #S? (y/n)" kill-session
# Merge session with another one (e.g. move all windows)
# If you use adhoc 1-window sessions, and you want to preserve session upon exit
# but don't want to create a lot of small unnamed 1-window sessions around
# move all windows from current session to main named one (dev, work, etc)
bind C-u command-prompt -p "Session to merge with: " \
"run-shell 'yes | head -n #{session_windows} | xargs -I {} -n 1 tmux movew -t %%'"
# Detach from session
bind d detach
bind D if -F '#{session_many_attached}' \
'confirm-before -p "Detach other clients? (y/n)" "detach -a"' \
'display "Session has only 1 client attached"'
# ==================================================
# === Window monitoring for activity and silence ===
# ==================================================
bind m setw monitor-activity \; display-message 'Monitor window activity [#{?monitor-activity,ON,OFF}]'
bind M if -F '#{monitor-silence}' \
'setw monitor-silence 0 ; display-message "Monitor window silence [OFF]"' \
'command-prompt -p "Monitor silence: interval (s)" "setw monitor-silence %%"'
# Activity bell and whistles
set -g visual-activity on
# TODO: Does not work as well, check on newer versions
# set -g visual-silence on
# BUG: bell-action other ignored · Issue #1027 · tmux/tmux · GitHub - https://github.com/tmux/tmux/issues/1027
# set -g visual-bell on
# setw -g bell-action other
# ================================
# === Copy and scroll ===
# ================================
unbind "#" # list-buffer
unbind = # choose-buffer
unbind ] # paste-buffer
# Prefer vi style key table
setw -g mode-keys vi
# trigger copy mode by pressing PageUp key w/o prepending it with prefix key
bind -n PageUp copy-mode
bind Escape copy-mode
bind p paste-buffer
bind C-p choose-buffer
# Scroll up/down by 1 line, half screen, whole screen
bind -T copy-mode-vi M-Up send-keys -X scroll-up
bind -T copy-mode-vi M-Down send-keys -X scroll-down
bind -T copy-mode-vi M-PageUp send-keys -X halfpage-up
bind -T copy-mode-vi M-PageDown send-keys -X halfpage-down
bind -T copy-mode-vi PageDown send-keys -X page-down
bind -T copy-mode-vi PageUp send-keys -X page-up
# When scrolling with mouse wheel, reduce number of scrolled rows per tick to "2" (default is 5)
bind -T copy-mode-vi WheelUpPane select-pane \; send-keys -X -N 2 scroll-up
bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 2 scroll-down
# Do not copy selection and cancel copy mode on drag end event
# More iTerm style selection: select, then need to mouse click to copy to buffer
unbind -T copy-mode-vi MouseDragEnd1Pane
bind -T copy-mode-vi MouseDown1Pane select-pane \; send-keys -X copy-selection
# ===================================
# === Appearence and status bar ===
# ===================================
# TODO: Not ready yet
# source ~/.tmux/theme.conf
# ============================
# === Hooks ===
# ============================
# Prompt to rename window right after it's created
set-hook -g after-new-window 'command-prompt -I "#{window_name}" "rename-window '%%'"'
# ============================
# === Plugins ===
# ============================
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'tmux-plugins/tmux-sidebar'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-open'
# Plugin properties
set -g @batt_remain_short true
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_output_prefix '['
set -g @prefix_highlight_output_suffix ']'
set -g @online_icon "#[fg=green]●#[default]"
set -g @offline_icon "#[fg=red]●#[default]"
set -g @sidebar-tree 't'
set -g @sidebar-tree-focus 'T'
set -g @sidebar-tree-command 'tree -C'
set -g @open-S 'https://www.google.com/search?q='
# Run all plugins' scripts
run '~/.tmux/plugins/tpm/tpm'