Skip to content

Instantly share code, notes, and snippets.

@mtanzi
Created January 24, 2019 12:18
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 mtanzi/fcc980190bca9947cb422e909f45c403 to your computer and use it in GitHub Desktop.
Save mtanzi/fcc980190bca9947cb422e909f45c403 to your computer and use it in GitHub Desktop.
Tmux dotfiles
# improve colors
set -g default-terminal 'screen-256color'
# act like vim
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# act like GNU screen
unbind C-b
set -g prefix C-a
# start window numbers at 1 to match keyboard order with tmux window order
set -g base-index 1
set-window-option -g pane-base-index 1
# renumber windows sequentially after closing any of them
set -g renumber-windows on
# increase scrollback lines
set -g history-limit 10000
# switch to last pane
bind-key C-a last-pane
# Status Bar ---------------------
#
set -g status on
# soften status bar colors
set -g status-bg '#586e75'
set -g status-fg '#eee8d5'
# More colors from Solarized
# $base03: #002b36;
# $base02: #073642;
# $base01: #586e75;
# $base00: #657b83;
# $base0: #839496;
# $base1: #93a1a1;
# $base2: #eee8d5;
# $base3: #fdf6e3;
# $yellow: #b58900;
# $orange: #cb4b16;
# $red: #dc322f;
# $magenta: #d33682;
# $violet: #6c71c4;
# $blue: #268bd2;
# $cyan: #2aa198;
# $green: #859900;
# remove administrative debris (session name, hostname, time) in status bar
set -g status-left ''
set -g status-right ''
set -g status-justify centre
set-option -g status-left-length 50
set-option -g status-right "Battery: #{battery_icon} #{battery_percentage} #{battery_remain} | #(date '+%a, %b %d - %I:%M')"
set -g status-left "Session: #S"
#Allow mouse usage
set -g mouse on
# Shift + arrows to resize pane
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1
# 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"
#vi style selection and copying to clipboard
#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
#unbind -t vi-copy Enter
#bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
#copy paste to clipboard
#set-option -g default-command "reattach-to-user-namespace -l zsh" # or bash...
#bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
#bind C-v run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
bind-key h split-window -v -c '#{pane_current_path}'
bind-key v split-window -h -c '#{pane_current_path}'
bind-key c new-window -c '#{pane_current_path}'
bind-key k confirm kill-window
# Quickly edit todo list
bind-key t split-window -h "vim"
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
bind P paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
# List of plugins
# set -g @plugin 'tmux-plugins/tpm' # Tmux package manager
# set -g @plugin 'tmux-plugins/tmux-sensible'
# set -g @plugin 'tmux-plugins/tmux-open' # Open highlighted selection directly from Tmux
# set -g @plugin 'tmux-plugins/tmux-resurrect' # Restore previous sessions on reboot
# set -g @plugin 'tmux-plugins/tmux-continuum' # Restore previous sessions on reboot
# set -g @plugin 'tmux-plugins/tmux-battery' #Show battery icon/status
# Tmux will auto-start on system boot
# set -g @continuum-boot 'on'
# set -g @continuum-boot-options 'iterm'
# set -g @continuum-restore 'on'
# set -g @continuum-save-interval '5'
# set -g @resurrect-strategy-vim 'session'
# set -g @resurrect-strategy-nvim 'session' #for Neo Vim
# How to install other plugins from Github:
# To install new plugins press: prefix + I
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'
# Initializes Tmux plugin manager.
# Keep this line at the very bottom of tmux.conf.
# run-shell '~/.tmux/plugins/tpm/tpm'
# run '~/.tmux/plugins/tpm/tpm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment