Skip to content

Instantly share code, notes, and snippets.

@rachidcalazans
Last active November 7, 2020 11:36
Show Gist options
  • Save rachidcalazans/b9ede3f6e49450b41a5bbaff9ccc8cad to your computer and use it in GitHub Desktop.
Save rachidcalazans/b9ede3f6e49450b41a5bbaff9ccc8cad to your computer and use it in GitHub Desktop.
.tmux.conf
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# set first window to index 1 (not 0) to map more to the keyboard layout...
set-option -g base-index 1
set-window-option -g pane-base-index 1
set-window-option -g mouse on
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
# Ring the bell if any background window rang a bell
# set -g bell-action any
# Default termtype. If the rcfile sets $TERM, that overrides this value.
# set -g default-terminal screen-256color
# Create splits and vertical splits
bind-key v split-window -h -p 50 -c "#{pane_current_path}"
bind-key b split-window -p 50 -c "#{pane_current_path}"
# Pane resize in all four directions using vi bindings.
# Can use these raw but I map them to shift-ctrl-<h,j,k,l> in iTerm.
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 6
# vim-like pane switching
# bind -r k select-pane -U
# bind -r j select-pane -D
# bind -r h select-pane -L
# bind -r l select-pane -R
# Smart pane switching with awareness of vim splits.
# Source: https://github.com/christoomey/vim-tmux-navigator
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(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"
# color scheme (styled as vim-powerline)
set -g status-left-length 52
set -g status-right-length 451
set -g status-style fg=white,bg=colour234
set -g pane-border-style fg=colour245
set -g pane-active-border-style fg=colour39
set -g message-style fg=colour16,bg=colour221,bold
set -g status-left '#[fg=colour235,bg=colour252,bold] ❐ #S #[fg=colour252,bg=colour238,nobold]⮀#[fg=colour245,bg=colour238,bold] #(whoami) #[fg=colour238,bg=colour234,nobold]⮀'
set -g window-status-format '#[fg=colour235,bg=colour252,bold] #I #(pwd="#{pane_current_path}"; echo ${pwd####*/}) #W '
set -g window-status-current-format '#[fg=colour234,bg=colour39]⮀#[fg=black,bg=colour39,noreverse,bold] #{?window_zoomed_flag,#[fg=colour228],} #I #(pwd="#{pane_current_path}"; echo ${pwd####*/}) #W #[fg=colour39,bg=colour234,nobold]⮀'
set-option -g status-interval 2
# No escape time for vi mode
# set -sg escape-time 0
# Screen like binding for last window
bind C-a last-window
# Bigger history
# set -g history-limit 10000
# New windows/pane in $PWD
# bind c new-window -c "#{pane_current_path}"
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Local config
# if-shell "[ -f ~/.tmux.conf.user ]" 'source ~/.tmux.conf.user'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment