Created
February 27, 2019 01:15
-
-
Save geraldlai/4a2715f8612da24f91521b490e0c9192 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
# remap prefix | |
unbind C-b | |
set -g prefix C-Space | |
bind C-Space send-prefix | |
# 0 is too far | |
set -g base-index 1 | |
setw -g pane-base-index 1 | |
# vi bindings for copy mode | |
# emacs bindings for command mode | |
setw -g mode-keys vi | |
set -g status-keys emacs | |
# copying | |
set -g set-clipboard on | |
bind p paste-buffer -p | |
bind C-p paste-buffer -p | |
bind -T root M-v paste-buffer -p | |
bind PPage copy-mode -eu | |
bind NPage copy-mode -e | |
bind -T root M-PPage copy-mode -eu | |
bind -T root M-NPage copy-mode -e | |
bind -T copy-mode-vi M-PPage send -X page-up | |
bind -T copy-mode-vi M-NPage send -X page-down | |
bind -T copy-mode-vi v send -X begin-selection | |
bind -T copy-mode-vi y send -X copy-pipe 'yank > #{pane_tty}' \; send -X clear-selection | |
bind -T copy-mode-vi Enter send -X copy-pipe-and-cancel 'yank > #{pane_tty}' | |
# transfer copied text to attached terminal with yank: | |
# bind -T root M-y run-shell 'copycat' | |
bind -T root M-y run-shell 'tmux save-buffer - | yank > #{pane_tty}' | |
# transfer previously copied text (chosen from a menu) to attached terminal: | |
bind -T root M-Y choose-buffer 'run-shell "tmux save-buffer -b \"%%\" - | yank > #{pane_tty}"' | |
# search buffer (using less if Vim is not available) | |
bind -T root M-/ capture-pane -S - -J \; new-window -a -c '#{pane_current_path}' ' \ | |
tmux save-buffer - \; send -t $TMUX_PANE G \; \ | |
delete-buffer | { \ | |
vim -R -; \ | |
test $? -eq 127 && less; \ | |
}' | |
# no auto window rename | |
set -g allow-rename off | |
# activity alerts | |
setw -g monitor-activity on | |
set -g visual-activity on | |
# mouse | |
set -g mouse on | |
bind -T copy-mode-vi WheelUpPane select-pane \; send -X -N 1 scroll-up | |
bind -T copy-mode-vi WheelDownPane select-pane \; send -X -N 1 scroll-down | |
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe 'yank > #{pane_tty}' | |
bind -T root MouseDrag1Status swap-window -t= | |
bind -T root DoubleClick1Status new-window -a -c '#{pane_current_path}' | |
# misc | |
set -g default-terminal "screen-256color" | |
set -g xterm-keys on | |
set -g history-limit 100000 | |
set -sg escape-time 1 | |
# reload | |
bind r source-file ~/.tmux.conf \; display "Reloaded config" | |
# split panes | |
bind \ split-window -h -c '#{pane_current_path}' | |
bind - split-window -v -c '#{pane_current_path}' | |
unbind '"' | |
unbind % | |
# resize panes | |
bind -r C-Up resize-pane -U 5 | |
bind -r C-Down resize-pane -D 5 | |
bind -r C-Right resize-pane -R 5 | |
bind -r C-Left resize-pane -L 5 | |
bind -T root M-z resize-pane -Z | |
# smart pane switching | |
is_vim='echo "#{pane_current_command}" | grep -iqE -e "(^|\/)g?(view|n?vim?x?)(diff)?$"' | |
bind -T root M-Up if-shell "$is_vim" "send -l [1;3A" "select-pane -U" | |
bind -T root M-Down if-shell "$is_vim" "send -l [1;3B" "select-pane -D" | |
bind -T root M-Right if-shell "$is_vim" "send -l [1;3C" "select-pane -R" | |
bind -T root M-Left if-shell "$is_vim" "send -l [1;3D" "select-pane -L" | |
bind -T root M-x if-shell "$is_vim" "send M-x" "if-shell 'test #{window_panes} -gt 1' last-pane last-window" | |
# mouse middle-click | |
bind -T root MouseDown2Pane if-shell "$is_vim" "send -M MouseDown2" "paste-buffer -p" | |
# window actions | |
bind -T root M-c new-window -c '#{pane_current_path}' | |
bind -T root M-n command-prompt "rename-window '%%'" | |
bind -r -T root M-, select-window -t :- | |
bind -r -T root M-. select-window -t :+ | |
# pane actions | |
# format: [mysession:]window_id.pane_id, or mysession:progname (for unique progname) | |
bind Space display-panes | |
bind -T root M-< command-prompt -p "(pull pane from)" "join-pane -s '%%'" | |
bind -T root M-> command-prompt -p "(send pane to)" "join-pane -t '%%'" | |
bind -T root M-? if-shell "tmux split-window -dbv -c '#{pane_current_path}'" break-pane | |
# log output | |
bind C-s pipe-pane "tee -a '/tmp/tmux-#Wi-#T-#{window_activity_string}.log'" \; display "Logging to: /tmp/tmux-#Wi-#T-#{window_activity_string}.log" | |
# ==================== [ restyle ] ==================== | |
# panes | |
set -g pane-active-border-bg colour236 | |
set -g pane-active-border-fg colour51 | |
set -g pane-border-bg colour235 | |
set -g pane-border-fg colour238 | |
# window mode | |
setw -g clock-mode-colour colour135 | |
setw -g mode-attr bold | |
setw -g mode-bg colour238 | |
setw -g mode-fg colour196 | |
# window status | |
setw -g window-status-attr none | |
setw -g window-status-bell-attr bold | |
setw -g window-status-bell-bg colour1 | |
setw -g window-status-bell-fg colour255 | |
setw -g window-status-bg colour235 | |
setw -g window-status-fg colour138 | |
setw -g window-status-current-attr bold | |
setw -g window-status-current-bg colour238 | |
setw -g window-status-current-fg colour81 | |
setw -g window-status-current-format " #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F " | |
setw -g window-status-format " #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F " | |
# status line | |
set -g status-attr dim | |
set -g status-bg colour234 | |
set -g status-fg colour137 | |
set -g status-interval 2 | |
set -g status-justify left | |
set -g status-left "" | |
set -g status-left-length 20 | |
set -g status-position bottom | |
set -g status-right "#[fg=colour233,bg=colour238,bold] #S:#I.#P [#D] #[fg=colour233,bg=colour241,bold] %m/%d #[fg=colour233,bg=colour245,bold] %H:%M:%S " | |
set -g status-right-length 50 | |
# messages | |
set -g message-attr bold | |
set -g message-bg colour166 | |
set -g message-command-bg black | |
set -g message-command-fg blue | |
set -g message-fg colour232 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment