Skip to content

Instantly share code, notes, and snippets.

@antiboredom
Created April 23, 2021 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antiboredom/bd4e3e0834987ba589e6cb901c8cd579 to your computer and use it in GitHub Desktop.
Save antiboredom/bd4e3e0834987ba589e6cb901c8cd579 to your computer and use it in GitHub Desktop.
set-option -g default-terminal "screen-256color"
# set-option -g default-terminal "xterm-256color"
# History
set -g history-limit 10000
# Start windows at 1 rather than 0
set -g base-index 1
# bind-key -n M-/ copy-mode
# # linux system clipboard
# bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
# bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "xclip -in -selection clipboard"
# # macOS system clipboard
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "pbcopy"
# user vim keys for copying
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# bind -n M-Space copy-mode
# hjkl pane traversal
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# use alt keys
bind -n 'M-Left' select-pane -L
bind -n 'M-Down' select-pane -D
bind -n 'M-Up' select-pane -U
bind -n 'M-Right' select-pane -R
# Use Alt-vim keys without prefix key to switch panes
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
# Shift arrow to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
# start new panes and windows with the current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind s split-window -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"
# turn the mouse on
set -g mouse on
# vim keys
setw -g mode-keys vi
set-option -g status-keys vi
# No delay for escape key press
# set -g escape-time 1
set -sg escape-time 0
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# something about copying on a mac who knows
set-option -g default-command "reattach-to-user-namespace -l zsh"
# 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'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"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
# Set prefix to Ctrl-Space instead of Ctrl-b
# unbind C-b
# set -g prefix C-Space
# bind Space send-prefix
# THEME
# yellow/blue border
set -wg pane-border-style 'bg=black,fg=blue'
set -wg pane-active-border-style 'bg=black,fg=yellow'
# dim inactive panes
set -g window-style 'fg=colour252,bg=colour236'
set -g window-active-style 'fg=white,bg=black'
# STATUS STUFF
set -g status "on"
set -g status-bg "colour237"
set -g status-justify "left"
set -g status-position "top"
set -g status-left-length "100"
set -g status-right-length "100"
set -g status-left " #{prefix_highlight}#[fg=colour22,bg=colour148,bold] #S #[fg=colour148,bg=colour236,nobold,nounderscore,noitalics]"
# branch name and repo name / folder name
set -g status-right "#[fg=colour240,bg=colour236,nobold,nounderscore,noitalics]#[fg=colour250,bg=colour240] %Y-%m-%d %H:%M #[fg=colour252,bg=colour240,nobold,nounderscore,noitalics] #[fg=colour228,bg=colour238] #(cd #{pane_current_path}; basename `git rev-parse --show-toplevel`) #[fg=colour223,bg=colour238] #(cd #{pane_current_path}; git rev-parse --abbrev-ref HEAD | cut -c1-25) #[fg=colour250,bg=colour236] #h"
setw -g window-status-separator ""
setw -g window-status-format " #[fg=colour245,bg=colour236] #I #[fg=colour245,bg=colour236]#W "
setw -g window-status-current-format "#[fg=colour236,bg=colour240,nobold,nounderscore,noitalics]#[fg=colour231,bg=colour240] #I #[fg=colour231,bg=colour240]#{?window_zoomed_flag,#[fg=green][],}#W #[fg=colour240,bg=colour236,nobold,nounderscore,noitalics]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment