Created
March 21, 2019 11:59
-
-
Save andrey-utkin/4325c5ad4f251908ba0f438e653d369a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -g default-terminal "screen-256color" | |
# http://superuser.com/a/402084 | |
set-window-option -g xterm-keys on | |
##set -g default-command "reattach-to-user-namespace -l bash" | |
# Start numbering at 1 | |
set -g base-index 1 | |
# # Scroll History | |
set -g history-limit 30000 | |
# Basically allows for faster key repetition | |
set -s escape-time 0 | |
# Set status bar | |
set -g status-justify left | |
set -g status-bg black | |
set -g status-fg white | |
set-option -g status-interval 1 | |
set -g status-right-length 150 | |
set -g status-left "" | |
set -g status-right "#[fg=green] #(hostname) %Y-%m-%d %H:%M" | |
# Rather than constraining window size to the maximum size of any client | |
# connected to the *session*, constrain window size to the maximum size of any | |
# client connected to *that window*. Much more reasonable. | |
setw -g aggressive-resize on | |
# Highlight active window | |
set-window-option -g window-status-current-bg red | |
# Let tmux set title of termial connected to it. See set-titles-string | |
set set-titles on | |
# Shell, vim etc. set title of their terminal session. Reflect it in tmux window title. | |
set-window-option -g automatic-rename-format "#{pane_title}" | |
# Turn on vi bindings in copy mode | |
set-option -g status-keys vi | |
set-window-option -g mode-keys vi | |
bind-key -Tcopy-mode-vi 'v' send -X begin-selection | |
set-option -g set-clipboard off | |
bind-key -Tcopy-mode-vi 'y' send -X copy-pipe "xclip -sel clip -i -d :0" | |
bind-key y run-shell "tmux save-buffer - | xclip -sel clip -i -d :0" | |
# Reorder tabs as in Konsole | |
# (almost, watch out over-the-boundary swapping) | |
bind-key -n C-S-Left swap-window -t -1 | |
bind-key -n C-S-Right swap-window -t +1 | |
bind-key -T copy-mode-vi C-S-Left swap-window -t -1 | |
bind-key -T copy-mode-vi C-S-Right swap-window -t +1 | |
# Reorder tabs, works with default Konsole keybindings (which are hard to override) | |
# Also works in dumb 'st' terminal | |
bind-key -r -T prefix Left swap-window -t -1 | |
bind-key -r -T prefix Right swap-window -t +1 | |
# Traverse tabs as in Konsole | |
# Also, default binding for this is prefix+{p,n} | |
bind-key -n S-Left previous-window | |
bind-key -n S-Right next-window | |
bind-key -T copy-mode-vi S-Left previous-window | |
bind-key -T copy-mode-vi S-Right next-window | |
# select window with alt + number | |
bind-key -n M-1 select-window -t :=1 | |
bind-key -n M-2 select-window -t :=2 | |
bind-key -n M-3 select-window -t :=3 | |
bind-key -n M-4 select-window -t :=4 | |
bind-key -n M-5 select-window -t :=5 | |
bind-key -n M-6 select-window -t :=6 | |
bind-key -n M-7 select-window -t :=7 | |
bind-key -n M-8 select-window -t :=8 | |
bind-key -n M-9 select-window -t :=9 | |
bind-key -n M-0 select-window -t :=10 | |
bind-key -T copy-mode-vi M-1 select-window -t :=1 | |
bind-key -T copy-mode-vi M-2 select-window -t :=2 | |
bind-key -T copy-mode-vi M-3 select-window -t :=3 | |
bind-key -T copy-mode-vi M-4 select-window -t :=4 | |
bind-key -T copy-mode-vi M-5 select-window -t :=5 | |
bind-key -T copy-mode-vi M-6 select-window -t :=6 | |
bind-key -T copy-mode-vi M-7 select-window -t :=7 | |
bind-key -T copy-mode-vi M-8 select-window -t :=8 | |
bind-key -T copy-mode-vi M-9 select-window -t :=9 | |
bind-key -T copy-mode-vi M-0 select-window -t :=10 | |
# Go to window 10 instead of window 0 | |
bind-key 0 select-window -t :=10 | |
# new pane/window with current directory | |
# "prefix, c" for new window at position next to current | |
bind-key c new-window -a -c '#{pane_current_path}' | |
# "prefix, shift+c" for new window positioned at end of windows list | |
bind-key C new-window -c '#{pane_current_path}' | |
# Maintain lowest, ordered numbers for windows | |
set-option -g renumber-windows on | |
# Clear screen and scrollback by <prefix> Ctrl+x | |
bind-key -T prefix C-x send-keys -R \; clear-history | |
# Use Home and End to move naturally on a line in copy mode | |
bind -Tcopy-mode-vi Home send-keys -X back-to-indentation | |
bind -Tcopy-mode-vi End send-keys -X end-of-line | |
# Use ctrl+arrows in copy mode for fast motion | |
bind -Tcopy-mode-vi C-Right send-keys -X next-word-end | |
bind -Tcopy-mode-vi C-Left send-keys -X previous-word | |
# Mouse config from https://github.com/sc0ty/config/blob/master/.tmux.conf | |
set -gq mouse on | |
bind-key -n WheelUpPane \ | |
if-shell -Ft= "#{?pane_active,0,1}" "select-pane -t=" \; \ | |
if-shell -Ft= "#{pane_in_mode}" \ | |
"send-keys -M ; send-keys -M ; send-keys -M" \ | |
"if-shell -Ft= \"#{mouse_any_flag}\" \ | |
\"send-keys -M\" \ | |
\"if-shell -Ft= '#{alternate_on}' \ | |
'send-keys Up Up Up' \ | |
'copy-mode -e'\"" | |
bind-key -n WheelDownPane \ | |
if-shell -Ft= "#{?pane_active,0,1}" "select-pane -t=" \; \ | |
if-shell -Ft= "#{pane_in_mode}" \ | |
"send-keys -M ; send-keys -M ; send-keys -M" \ | |
"if-shell -Ft= \"#{mouse_any_flag}\" \ | |
\"send-keys -M\" \ | |
\"if-shell -Ft= '#{alternate_on}' \ | |
'send-keys Down Down Down'\"" | |
# select window by mouse click also in copy mode | |
bind-key -T copy-mode-vi MouseDown1Status select-window -t = | |
# paste with middle click | |
bind-key -n MouseDown2Pane run "xclip -sel clip -o | tmux load-buffer - ; tmux paste-buffer" | |
# paste with prefix, v | |
bind-key -T prefix v run "xclip -sel clip -o | tmux load-buffer - ; tmux paste-buffer" | |
# paste with prefix, ctrl+v | |
bind-key -T prefix C-v run "xclip -sel clip -o | tmux load-buffer - ; tmux paste-buffer" | |
# drag & drop windows on status line by mouse | |
bind-key -n MouseDrag1Status swap-window -t= | |
# new window by right click on status line | |
bind-key -n MouseDown3Status new-window -a -t= -c '#{pane_current_path}' | |
# new window in background by middle click on status line | |
bind-key -n MouseDown2Status new-window -ad -t= -c '#{pane_current_path}' | |
# don't scroll to bottom after mouse select | |
# put selection to X clipboard after selection | |
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe "xclip -sel clip -i -d :0" \; send-keys -X copy-selection | |
# exit from copy-mode with right-click | |
unbind-key -n MouseDown3Pane | |
bind-key -T copy-mode-vi MouseDown3Pane send-keys -X cancel | |
bind-key p run-shell "pstree -alpU #{pane_pid}" | |
# # Tmux Plugin Manager | |
# # List of plugins | |
# set -g @plugin 'tmux-plugins/tpm' | |
# set -g @plugin 'tmux-plugins/tmux-sensible' | |
# set -g @plugin 'tmux-plugins/tmux-logging' | |
# set -g @plugin 'tmux-plugins/tmux-resurrect' | |
# set -g @plugin 'tmux-plugins/tmux-continuum' | |
# set -g @plugin 'tmux-plugins/tmux-copycat' | |
# set -g @plugin 'tmux-plugins/tmux-open' | |
# | |
# #set -g @continuum-restore 'on' | |
# | |
# # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) | |
# run '~/.tmux/plugins/tpm/tpm' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment