aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/%HOME%/.tmux.conf
blob: 21db6d6b3c1011c2dfb2c15d8f3bf91d167ee8a5 (plain) (tree)
1
2
3
4
5
6
7
8
9
10






                                                                                                  


                                      
                       
 





                                                                             


                                 






















                                                                           
                                                                
 



                                         
              
              
 

                                  

                                        
 
























                                                                            



                        















                                                     






                                                                         



                                                                                                          
                                                                                              

                                                                                                     
                                                                               

 


                  
                                                                              
                                  




                                                                                                                           
                                                                                                                     

                                                                                                                      
                                                                    

 











                                                                                           
            
            
 
                                 
 



                                                                  
 
                                                                   
# [1]: https://wiki.archlinux.org/index.php/tmux
# [2]: https://gist.github.com/Lartza/6a7a62466a8a3e436234412d9b1c5066
# [3]: http://mutelight.org/practical-tmux
# [4]: https://github.com/tmux-plugins/tmux-sensible
# [5]: https://github.com/tmux-plugins/tmux-yank
# [6]: https://github.com/greymd/dotfiles/blob/333c46dab103d4316a83744dec28605dc2cbc4ab/.tmux.conf

# C-b is hella uncomfortable to press.
unbind C-b
set -g prefix C-j
bind -n M-j send-prefix

# The default seems to be "screen" on my machine, and if I ssh to a remote
# system, all the 256 colors might not be supported. Check using this script:
# https://superuser.com/a/285400. I'm eager to see what kinds of trouble it
# will bring me.
set -g default-terminal "screen-256color"

# Why launch a login shell?
set -g default-command "${SHELL}"

# Numbering starts at 1 instead of 0.
set -g base-index 1
set-window-option -g pane-base-index 1

# I'm not sure about this. Still, it's recommended by tmux-sensible, etc.
set -s escape-time 0

# Enable mouse support. You can now scroll inside panes. It automatically
# enters copy mode though, which you can exit by pressing q. Right click to
# bring up the emulator's context window won't work though, hold Shift for
# that.
set -g mouse on

# Default is only 2000 lines?!
set -g history-limit 50000

# Show tmux messages for a longer time (0.75 seconds is the default).
set -g display-time 4000

# Refresh the status line more often (every 15 second is the default).
set -g status-interval 5

# The following settings I don't totally understand/need, but they looked
# sensible enough, and they were recommended at least somewhere.

set -g focus-events on

set-window-option -g aggressive-resize on

# Key bindings
# ------------

# X to kill the current session.
bind X confirm-before kill-session
# A to kill all but the current session.
bind A confirm-before 'kill-session -a'

# R to reload this file.
bind R source-file ~/.tmux.conf \; display "Reloaded!"

# According to tmux-sensible, it's more natural to use default readline-like
# key bindings in the command prompt; I sorta agree.
set -g status-keys emacs

# Start new windows/panes in the current directory.
bind c new-window -c "#{pane_current_path}"
# The defaults for pane splitting are the dumbest bindings I've ever seen.
bind - split-window -v -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"

# Switch between panes quicker.
bind -n M-1 select-pane -t 1
bind -n M-2 select-pane -t 2
bind -n M-3 select-pane -t 3
bind -n M-4 select-pane -t 4
bind -n M-5 select-pane -t 5
bind -n M-6 select-pane -t 6
bind -n M-7 select-pane -t 7
bind -n M-8 select-pane -t 8
bind -n M-9 select-pane -t 9
bind -n M-0 select-pane -t 0

bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R

# Copy mode bindings
# ------------------

# I looked up useful bindings here[2] and there[5].

# Don't care if $EDITOR is not set up, I'm a vim guy.
set -g mode-keys vi

# This I'm unsure about.
bind Escape copy-mode
# This I'm sure about.
bind-key -T copy-mode-vi v send -X begin-selection

# Using the system clipboard.

# y to copy to the system clipboard.
# Y to immediately insert in the current pane.
# M-y is y and Y combined.
# ! to copy excluding line endings (most useful for one-line selections).

# 1. Cygwin

if-shell 'uname | grep -q -F CYGWIN' {
  bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard'
  bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer'
  bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard; tmux paste-buffer'
  bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel "tr -d '\n' > /dev/clipboard"
  bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard'
  bind-key -T root MouseDown2Pane run 'cat /dev/clipboard | tmux load-buffer - && tmux paste-buffer'
  bind-key ] run 'cat /dev/clipboard | tmux load-buffer - && tmux paste-buffer'
}

# 2. Linux

# Depends on xsel.
# The simple `xsel -i --clipboard` doesn't work, but `xsel -i -p && xsel -o -p
# | xsel -i -b` [1] does. How fun!

if-shell 'uname | grep -q -F Linux && which xsel' {
  bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b'
  bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer'
  bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b; tmux paste-buffer'
  bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel "tr -d '\n' | xsel -i -p && xsel -o -p | xsel -i -b"
  bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b'
  bind-key -T root MouseDown2Pane run 'xsel -o | tmux load-buffer - && tmux paste-buffer'
  bind-key ] run 'xsel -o | tmux load-buffer - && tmux paste-buffer'
}

# 3. macOS

if-shell 'uname | grep -q -F Darwin' {
  bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'pbcopy'
  bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer'
  bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'pbpaste; tmux paste-buff'
  bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel "tr -d '\n' | pbcopy"
  bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'pbcopy'
  bind-key -T root MouseDown2Pane run 'pbpaste | tmux load-buffer - && tmux paste-buffer'
  bind-key ] run 'pbpaste | tmux load-buffer - && tmux paste-buffer'
}

# Appearance
# ----------

set -g status-right "%d %b %H:%M"

# Might not work so well depending on your color scheme.

set -g status-style fg=white,bg=blue
set-window-option -g window-status-current-style fg=black,bg=white

set-window-option -g pane-active-border-style bg=colour7,fg=colour9