Created
May 26, 2020 16:02
-
-
Save hkdsun/f11ad18bec6699c69f16899e6e117c5b 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
# Use vim bindings | |
setw -g mode-keys vi | |
set-option -g default-shell /bin/zsh | |
# unbind-key -a | |
unbind C-m | |
unbind C-b | |
unbind C-a | |
set-option -g prefix C-a | |
# bind-key y run-shell "tmux save-buffer - | reattach-to-user-namespace pbcopy" | |
if-shell "uname | grep -q Darwin" 'set -g default-command "reattach-to-user-namespace -l zsh"' | |
bind-key C-b send-prefix | |
# Set XTerm key bindings | |
setw -g xterm-keys on | |
# Set colors | |
set-option -g default-terminal "screen-256color" | |
# Set reload key to r | |
bind r source-file ~/.tmux.conf | |
# Count sessions start at 1 | |
set -g base-index 1 | |
set-window-option -g pane-base-index 1 | |
# big history | |
set -g history-limit 100000 | |
bind c new-window -c "#{pane_current_path}" | |
bind C-s split-window -c "#{pane_current_path}" | |
bind C-v split-window -h -c "#{pane_current_path}" | |
bind C-a last-window | |
bind C-q kill-pane | |
# Clear history | |
# bind C-k send-keys -R \; clear-history | |
bind C-k send-keys 'clear' C-m \; clear-history | |
# Set the title bar | |
set -g set-titles on | |
set -g set-titles-string '#(whoami) :: #h' | |
bind C-u copy-mode | |
# vim-style switching between panes | |
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-h) || tmux select-pane -L" | |
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-j) || tmux select-pane -D" | |
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-k) || tmux select-pane -U" | |
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|vim?)(diff)?$' && tmux send-keys C-l) || tmux select-pane -R" | |
# Use Alt-arrow keys without prefix key to switch panes | |
bind -n M-c new-window -c "#{pane_current_path}" | |
bind -n M-q kill-pane | |
bind -n M-h prev | |
bind -n M-l next | |
bind -n M-z resize-pane -Z | |
bind -n M-Left resize-pane -L \; resize-pane -L \; resize-pane -L | |
bind -n M-Right resize-pane -R \; resize-pane -R \; resize-pane -R | |
bind -n M-Up resize-pane -U \; resize-pane -U \; resize-pane -U | |
bind -n M-Down resize-pane -D \; resize-pane -D \; resize-pane -D | |
bind-key C-n select-window -t +1 | |
bind-key C-p select-window -t -1 | |
# vim-style yanking and pasting | |
unbind [ | |
bind [ copy-mode | |
unbind p | |
bind p paste-buffer | |
# bind-key -t vi-copy 'v' begin-selection | |
# bind-key -t vi-copy 'y' copy-selection | |
bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S -32768 ; save-buffer %1 ; delete-buffer' | |
set -s escape-time 0 | |
set -g mouse on | |
# List of plugins | |
set -g @plugin 'tmux-plugins/tpm' | |
set -g @plugin 'tmux-plugins/tmux-yank' | |
set -g @plugin 'tmux-plugins/tmux-sidebar' | |
# status bar | |
set -g status-justify left | |
set -g status-bg default | |
set -g status-fg white | |
set -g status-interval 5 | |
set -g status-position bottom | |
set -g status-left '' | |
set -g status-right '#(~/.tmux/get_status_right)' | |
set -g status-right-length 100 | |
set -g status-left-length 60 | |
window_status='#[fg=white]#{window_index}:#(echo "#{pane_current_path}" | rev | cut -d'/' -f-3 | rev)#[fg=white] ' | |
window_status_current='#[fg=white]#{window_index}:#(echo "#{pane_current_path}" | rev | cut -d'/' -f-3 | rev)#[fg=white]*' | |
set-window-option -g window-status-current-format "$window_status_current" | |
set-window-option -g window-status-format "$window_status" | |
set -g status-bg default | |
set -g status-fg white | |
set-option -g renumber-windows on | |
# Smart pane switching with awareness of Vim splits. | |
# See: https://github.com/christoomey/vim-tmux-navigator | |
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" | |
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" | |
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" | |
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" | |
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" | |
bind -T root F12 \ | |
set prefix None \;\ | |
set key-table off \;\ | |
set status-bg "colour088" \;\ | |
set status-fg black \;\ | |
set-window-option window-status-current-format '----- DISABLED (#(hostname)): Remote Session Enabled ------' \;\ | |
set-window-option -g window-status-format '' \;\ | |
set -g status-right '' \;\ | |
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ | |
refresh-client -S \;\ | |
bind -T off F12 \ | |
set -u prefix \;\ | |
set -u key-table \;\ | |
set -u status-style \;\ | |
set -u status-bg \;\ | |
set-window-option -u window-status-current-format \;\ | |
set-window-option -g window-status-format "$window_status" \;\ | |
set -g status-right '#(~/.tmux/get_status_right)' \;\ | |
refresh-client -S | |
if-shell 'test -n "$SSH_CONNECTION"' 'source-file ~/.tmux/tmux.remote.conf' | |
# 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