Last active
January 14, 2021 11:55
-
-
Save rmed/8458f71044a57694de29 to your computer and use it in GitHub Desktop.
tmux configuration
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 C-a instead of C-b as the prefix | |
set -g prefix C-a | |
unbind-key C-b | |
bind-key C-a send-prefix | |
# set 256 colors | |
set -g default-terminal "screen-256color" | |
#set -g terminal-overrides "xterm:colors=256" | |
# vim compatibility | |
set-window-option -g xterm-keys on | |
# set default shell | |
set -g default-command "exec /bin/bash" | |
set -g display-time 2000 | |
# set vi style key binding | |
set -g status-keys vi | |
setw -g mode-keys vi | |
# be more responsive, changing the default delay | |
set -sg escape-time 1 | |
# set scrollback | |
set -g history-limit 10000 | |
# Start numbering at 1 | |
set -g base-index 1 | |
setw -g pane-base-index 1 | |
# force a reload of the config file | |
unbind r | |
bind r source-file ~/.tmux.conf \; display "Reloaded!" | |
# automatic window renaming | |
set-window-option -g automatic-rename on | |
# aggresive resize | |
setw -g aggressive-resize on | |
# Create new session | |
bind N new-session | |
# Saner splitting. | |
bind v split-window -h -c '#{pane_current_path}' | |
bind s split-window -v -c '#{pane_current_path}' | |
bind S choose-session | |
bind c new-window -c '#{pane_current_path}' | |
# Pane resizing | |
bind -r H resize-pane -L 5 | |
bind -r J resize-pane -D 5 | |
bind -r K resize-pane -U 5 | |
bind -r L resize-pane -R 5 | |
# Vim-like copy-paste | |
unbind [ | |
bind - copy-mode | |
# unbind p | |
# bind p paste-buffer | |
# set colors | |
set -g status-bg colour234 | |
set -g window-status-activity-attr bold | |
set -g pane-border-fg colour245 | |
set -g pane-active-border-fg colour39 | |
set -g message-fg colour16 | |
set -g message-bg colour221 | |
set -g message-attr bold | |
# Custom status bar | |
# Powerline symbols: | |
set -g status-utf8 on | |
set -g status-left-length 32 | |
set -g status-right-length 150 | |
set -g status-interval 2 | |
set -g status-left '#[fg=colour15,bg=colour238,bold] #S #[fg=colour238,bg=colour234,nobold]' | |
set -g status-right '#[fg=colour245] %R #[fg=colour255,bg=colour234,nobold]#[fg=colour16,bg=colour254,bold] #h ' | |
set -g window-status-format "#[fg=white,bg=colour234] #I #W " | |
set -g window-status-current-format "#[fg=colour234,bg=colour39]#[fg=colour16,bg=colour39,noreverse,bold] #I #W #F #[fg=colour39,bg=colour234,nobold]" | |
# Activity | |
setw -g monitor-activity on | |
set -g visual-activity off | |
# Restore vim session | |
set -g @resurrect-strategy-vim "session" | |
# Log output to a text file on demand | |
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log" | |
# move between panes | |
# bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L" | |
# bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" | |
# bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U" | |
# bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" | |
# | |
# Smart pane switching with awareness of vim splits | |
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"' | |
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" | |
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" | |
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" | |
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" | |
bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" | |
# List of plugins | |
# Supports `github_username/repo` or full git URLs | |
set -g @tpm_plugins " \ | |
tmux-plugins/tpm \ | |
tmux-plugins/tmux-sensible \ | |
tmux-plugins/tmux-resurrect \ | |
tmux-plugins/tmux-continuum \ | |
tmux-plugins/tmux-yank \ | |
" | |
# Other examples: | |
# github_username/plugin_name \ | |
# git@github.com/user/plugin \ | |
# git@bitbucket.com/user/plugin \ | |
# initializes TMUX plugin manager | |
run-shell ~/.tmux/plugins/tpm/tpm | |
# Mouse stuff | |
# setw -g mode-mouse off | |
# setw -g mouse-select-window off | |
# setw -g mouse-select-pane off | |
# setw -g mouse-resize-pane off | |
# Disable automatic save | |
set -g @continuum-save-interval '0' | |
# Automatically restore tmux sessions | |
set -g @continuum-restore 'on' | |
# If run as "tmux attach", create session if none exist | |
new-session -n $HOST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment