Skip to content

Instantly share code, notes, and snippets.

@denniswon
Created March 18, 2020 21:58
Show Gist options
  • Save denniswon/edac9a52102621b2aec27115172afb6f to your computer and use it in GitHub Desktop.
Save denniswon/edac9a52102621b2aec27115172afb6f to your computer and use it in GitHub Desktop.
tmux conf
# Load plugins.
set -g @plugin 'tmux-plugins/tmux-yank' # Cross-platform support for clipboard.
set -g @plugin 'odedlaz/tmux-onedark-theme' # OneDark Theme
set -g @plugin 'tmux-plugins/tmux-resurrect' # Save/Restore sessions
set -g @plugin 'tmux-plugins/tmux-continuum' # Auto Save/Restore
# Remap prefix to ctrl-a for screen consistency.
# set -g prefix C-a
# Restore using continuum.
set -g @continuum-restore 'on'
# Shell management.
# Set the default shell, and set the default command to use our shell (this
# means we source things properly, show the correct PS1 etc).
set -g default-shell ${SHELL}
set -g default-command ${SHELL}
# Mouse management.
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
# Colour management (yikes).
# Use 256 colours.
set-option -ga terminal-overrides ",xterm-256color:Tc"
set-option -g default-terminal "screen-256color"
# Keyboard Management.
# Don't wait for an escape sequence after hitting
# Esc. fixes insert mode exit lag in vim.
set -sg escape-time 0
# Clipboard / Copy / Paste
# Note: This is heavily OS dependent, which is why we have separate versions
# for OSX, Ubuntu etc. I'm trying out tmux-yank for this but it is still work in
# progress.
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' begin/end selection as in Vim.
# bind-key -T copy-mode-vi v send-keys -X begin-selection
# setup 'v' to begin selection as in vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# update default binding of `Enter` to also use copy-pipe (os x)
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# Pane and Window Management.
# Open new panes and splits in the same working directory.
bind c new-window -c "#{pane_current_path}"
# Set the name of the window initially, but then don't let tmux change it.
# The name can still be set at any time with Ctrl+B + ,
set-option -g allow-rename off
# Ctrl+B h/l to swap windows.
bind-key h swap-window -t -1
bind-key l swap-window -t +1
# Start windows and panes at 1.
set -g base-index 1
set -g pane-base-index 1
# Split panes using | and -
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# 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-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
bind-key -T copy-mode-vi C-\ select-pane -l
# Enable focus events, which are needed to keep vim's focus events working when
# vim is running inside tmux.
set -g focus-events on
## Status bar design
# set -g status-utf8 on
set -g status-justify left
set -g status-bg default
set -g status-interval 2
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# Customise the visuals on top of One Dark for tmux. Might be good to put into
# its own file at some stage.
onedark_black="#282c34"
dark_black="#1c1c1c"
white="#ffffff"
set -g pane-border-bg "$onedark_black"
set -g pane-border-fg colour238
set -g pane-active-border-bg "$onedark_black"
set -g pane-active-border-fg colour14
# Info on left (I don't have a session display for now)
set -g status-left ''
# loud or quiet?
set-option -g visual-activity off
set-option -g visual-bell off
set-option -g visual-silence off
set-window-option -g monitor-activity off
set-option -g bell-action none
set -g status-position bottom
set -g status-bg colour234
set -g status-fg colour137
set -g status-attr dim
set -g status-left ''
set -g status-left-bg "$dark_black"
set -g status-right '#[fg=colour245] %Y-%m-%d #[fg=colour245] %H:%M:%S '
# setw -g status-right-fg colour138
# setw -g status-right-bg "$dark_black"
set -g status-right-length 50
set -g status-left-length 20
setw -g window-status-current-fg colour14
setw -g window-status-current-bg colour238
setw -g window-status-current-attr bold
setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F '
setw -g window-status-fg colour138
setw -g window-status-bg "$dark_black"
setw -g window-status-attr none
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
setw -g window-status-bell-attr bold
setw -g window-status-bell-fg colour255
setw -g window-status-bell-bg colour1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment