Skip to content

Instantly share code, notes, and snippets.

@kinwahlai
Created April 3, 2020 23:24
Show Gist options
  • Save kinwahlai/8703f04ffc752d004cbb0925d09db922 to your computer and use it in GitHub Desktop.
Save kinwahlai/8703f04ffc752d004cbb0925d09db922 to your computer and use it in GitHub Desktop.
# Borrowed & adapted from: https://github.com/brantb/dotfiles/blob/master/tmux.conf
# Set prefix to Ctrl-Space
unbind C-b
set-option -g prefix C-a
# using C-a as the tmux prefix comes at the cost of some great features:
# bash: move to start of line (in emacs mode, aka when i'm ssh'd somewhere)
# vim: insert mode increment number
# this allows you to access those same features by hitting (C-a a)
bind a send-prefix
# Use vi keys
set -gw mode-keys vi
# don't require changing to normal mode to traverse command history
bind-key -t vi-edit Up history-up
bind-key -t vi-edit Down history-down
set-option -g history-limit 10000
# hey tmux! use the system clipboard.
# this will work if you're using mvim from within the terminal
set-option -g default-command "reattach-to-user-namespace -l bash"
# so you don't end up with window numbers like: 0 1 4 5 6
set-option -g renumber-windows on
# Mouse support
set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-select-window on
setw -g mode-mouse copy-mode
# 256 color support
set -g default-terminal "screen-256color"
# Start window numbers from 1
set -g base-index 1
# set escape time so vim is responsive inside tmux
set -g escape-time 1
# prefix r: reload tmux config
bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
# make new panes and windows use the pwd
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# smart pane switching with awareness of vim splits
# makes ctrl-j and ctrl-k navigate fzf search results when fzf active in pane
# providing the same behavior as ctrl-j and ctrl-k when navigating ctrl-p results
# inside vim.
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"
bind -n C-h run "($is_vim && tmux send-keys C-h) || \
tmux select-pane -L"
bind -n C-j run "($is_vim && tmux send-keys C-j) || \
($is_fzf && tmux send-keys C-j) || \
tmux select-pane -D"
bind -n C-k run "($is_vim && tmux send-keys C-k) || \
($is_fzf && tmux send-keys C-k) || \
tmux select-pane -U"
bind -n C-l run "($is_vim && tmux send-keys C-l) || \
tmux select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# use `<prefix> [` to enter copy-mode
bind-key [ copy-mode
unbind-key C-[
bind-key ] paste-buffer
# use 'v' to begin selection in copy mode, similar entering visual mode in Vim
bind-key -t vi-copy v begin-selection
# use 'y' to yank selected text to system clipboard in copy mode, similar to yanking
# from visual selection in Vim
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# Status Bar
set-option -g status-interval 1
#### COLOUR (Solarized 256)
## default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
#
## default window title colors
set-window-option -g window-status-fg colour244 #base0
set-window-option -g window-status-bg default
#
## active window title colors
set-window-option -g window-status-current-fg colour50 # lightblue
set-window-option -g window-status-current-bg default
#
## pane border
set-option -g pane-border-fg white #base02
set-option -g pane-active-border-fg colour240 #base01
#
## message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange
#
## pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange
#
## clock
set-window-option -g clock-mode-colour colour43 #green
set -g status-utf8 on
# visual notification of activity in other windows
setw -g monitor-activity on
set -g visual-activity on
# make iterm window/tab name reflect tmux session
set-option -g set-titles on
set-option -g set-titles-string '#S'
# This tmux statusbar config was created by tmuxline.vim: on Wed, 12 Oct 2016
# and then customized by @keeganlow
set -g status-bg "colour67"
set -g message-command-fg "colour253"
set -g status-justify "left"
set -g status-left-length "100"
set -g status "on"
#set -g pane-active-border-fg "colour144"
set -g message-bg "colour16"
set -g status-right-length "100"
set -g status-right-attr "none"
set -g message-fg "colour253"
set -g message-command-bg "colour16"
set -g status-attr "none"
set -g status-utf8 "on"
set -g pane-border-fg "colour16"
set -g status-left-attr "none"
setw -g window-status-fg "colour253"
setw -g window-status-attr "none"
setw -g window-status-activity-bg "colour67"
setw -g window-status-activity-attr "none"
setw -g window-status-activity-fg "colour144"
setw -g window-status-separator ""
setw -g window-status-bg "colour67"
set -g status-left "#[fg=colour232,bg=colour144] #S #[fg=colour144,bg=colour67,nobold,nounderscore,noitalics]"
# indicate whether Prefix has been captured + time in the right-status area
set -g status-right '#[fg=colour144,bg=colour67,nobold,nounderscore,noitalics]#[fg=colour232,bg=colour144]#{?client_prefix,🚀 🚀 🚀,} %H:%M '
setw -g window-status-format "#[fg=colour253,bg=colour67] #I #[fg=colour253,bg=colour67] #W "
setw -g window-status-current-format "#[fg=colour67,bg=colour16,nobold,nounderscore,noitalics]#[fg=colour253,bg=colour16] #I #[fg=colour253,bg=colour16] #W #[fg=colour16,bg=colour67,nobold,nounderscore,noitalics]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment