Skip to content

Instantly share code, notes, and snippets.

@xeroc
Created July 30, 2019 09:24
Show Gist options
  • Save xeroc/bc5f8c68a5dde0d267e66bb9427eeeca to your computer and use it in GitHub Desktop.
Save xeroc/bc5f8c68a5dde0d267e66bb9427eeeca to your computer and use it in GitHub Desktop.
# https://thoughtbot.com/blog/migrating-from-screen-to-tmux
# https://github.com/sbernheim4/dotfiles/blob/master/.tmux.conf
set-option -g default-shell $SHELL
unbind C-b
# Set the prefix to `ctrl + a` instead of `ctrl + b`
set -g prefix C-a
#bind C-a send-prefix
bind C-a last-window
bind space next-window
# Use | and - to split a window vertically and horizontally instead of " and % respoectively
bind c new-window -c '#{pane_current_path}'
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# Switch betewen panes using alt + arrow
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Use shift + arrow key to move between windows in a session
bind -n S-Left previous-window
bind -n S-Right next-window
# Use m to toggle mouse mode
unbind m
bind m setw mouse
set -g mouse on
set-window-option -g mode-keys vi
# Setup 'v' to begin selection, just like Vim
bind-key -T copy-mode-vi 'v' send -X begin-selection
# Setup 'y' to yank (copy), just like Vim
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi 'V' send -X select-line
bind-key -T copy-mode-vi 'r' send -X rectangle-toggle
# Use r to quickly reload tmux settings
unbind r
bind r \
source-file ~/.tmux.conf \;\
display 'Reloaded tmux config'
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#############################
########## Settings
#############################
# Refresh status line every 5 seconds - Good for when music is playing / update time etc
set -g status-interval 5
# Start window and pane indices at 1.
set -g base-index 1
set -g pane-base-index 1
# length of tmux status line
set -g status-left-length 30
set -g status-right-length 150
# Make active pane border blue
set -g pane-active-border-style fg=colour1
#Set the left and right status
set -g status-left '#[bg=colour7]#[fg=colour0]#{?client_prefix,#[bg=colour2],} ❐ #S #[bg=colour0]#[fg=colour7]#{?client_prefix,#[fg=colour2],}#{?window_zoomed_flag, 🔍 ,}#[fg=colour1] ♥ #(~/dotfiles/tmux_scripts/battery.sh) '
set -g status-right '#[fg=colour7]#[bg=colour7] #[fg=colour2]#(~/dotfiles/tmux_scripts/uptime.sh) #[fg=colour1]#[fg=colour3]#[bg=colour3]#[fg=colour0] #(~/dotfiles/tmux_scripts/music.sh) #[bg=colour3]#[fg=colour1]#[bg=colour1]#[fg=colour0] %b %d %H:%M '
# Set the background color
set -g status-bg colour0
# customize how windows are displayed in the status line
set -g window-status-current-format "#[fg=colour0]#[bg=colour4]#[fg=colour7]#[bg=colour4] #I* #[fg=colour7] #W #[fg=colour4]#[bg=colour0]"
set -g window-status-format "#[fg=colour244]#[bg=colour0]#I-#[fg=colour240]  #W"
# Set the history limit so we get lots of scrollback.
setw -g history-limit 50000
#############################
############# Tmux Vars
#############################
# $(echo $USER) - shows the current username
# %a --> Day of week (Mon)
# %A --> Day of week Expanded (Monday)
# %b --> Month (Jan)
# %d --> Day (31)
# %Y --> Year (2017)
# %D --> Month/Day/Year (12/31/2017)
# %v --> Day-Month-Year (31-Dec-2017)
# %r --> Hour:Min:Sec AM/PM (12:30:27 PM)
# %T --> 24 Hour:Min:Sec (16:30:27)
# %X --> Hour:Min:Sec (12:30:27)
# %R --> 24 Hour:Min (16:30)
# %H --> 24 Hour (16)
# %l --> Hour (12)
# %M --> Mins (30)
# %S --> Seconds (09)
# %p --> AM/PM (AM)
# For a more complete list view: https://linux.die.net/man/3/strftime
#colour0 (black)
#colour1 (red)
#colour2 (green)
#colour3 (yellow)
#colour4 (blue)
#colour7 (white)
#colour5 colour6 colour7 colour8 colour9 colour10 colour11 colour12 colour13 colour14 colour15 colour16 colour17
#D ()
#F ()
#H (hostname)
#I (window index)
#P ()
#S (session index)
#T (pane title)
#W (currnet task like vim if editing a file in vim or zsh if running zsh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment