|
| 1 | +# Hierarchy: |
| 2 | +# Server |
| 3 | +# ㄴSession |
| 4 | +# ㄴWindow |
| 5 | +# ㄴPane |
| 6 | + |
| 7 | +# Options: |
| 8 | +# - Session options (set-option [-g]) |
| 9 | +# - Window options (set-window-option [-g]) |
| 10 | + |
| 11 | +# ------------------------------------------------------------------- |
| 12 | +# Session options |
| 13 | +# ------------------------------------------------------------------- |
| 14 | +# Change bind key to ctrl-a |
| 15 | +unbind-key c-b |
| 16 | +set-option -g prefix c-a |
| 17 | + |
| 18 | +# Index starts from 1 |
| 19 | +set-option -g base-index 1 |
| 20 | + |
| 21 | +# Renumber windows when a window is closed |
| 22 | +set-option -g renumber-windows on |
| 23 | + |
| 24 | +# History |
| 25 | +set-option -g history-limit 102400 |
| 26 | + |
| 27 | +# Repeat time limit (ms) |
| 28 | +set-option -g repeat-time 500 |
| 29 | + |
| 30 | +# 256-color terminal |
| 31 | +set-option -g default-terminal "screen-256color" |
| 32 | + |
| 33 | +# Key binding in the status line (bind-key :) |
| 34 | +set-option -g status-keys emacs |
| 35 | + |
| 36 | +# Mouse |
| 37 | +set-option -g mouse on |
| 38 | + |
| 39 | +# Escape delay |
| 40 | +set -s escape-time 0 |
| 41 | +# ------------------------------------------------------------------- |
| 42 | +# Window options |
| 43 | +# ------------------------------------------------------------------- |
| 44 | +# Copy-mode |
| 45 | +set-window-option -g mode-keys vi |
| 46 | + |
| 47 | +# ------------------------------------------------------------------- |
| 48 | +# Key bindings |
| 49 | +# ------------------------------------------------------------------- |
| 50 | +# prefix c |
| 51 | +bind-key c new-window -c "#{pane_current_path}" |
| 52 | + |
| 53 | +# prefix ctrl-a |
| 54 | +bind-key c-a last-window |
| 55 | + |
| 56 | +# prefix a |
| 57 | +bind-key a send-prefix |
| 58 | + |
| 59 | +# prefix | |
| 60 | +bind-key | split-window -h -c "#{pane_current_path}" |
| 61 | + |
| 62 | +# prefix - |
| 63 | +bind-key - split-window -c "#{pane_current_path}" |
| 64 | + |
| 65 | +# Moving windows |
| 66 | +bind-key -r > swap-window -t :+ |
| 67 | +bind-key -r < swap-window -t :- |
| 68 | + |
| 69 | +# Back and forth |
| 70 | +bind-key bspace previous-window |
| 71 | +bind-key space next-window |
| 72 | +bind-key / next-layout # Overridden |
| 73 | + |
| 74 | +# Pane-movement |
| 75 | +bind-key h select-pane -L |
| 76 | +bind-key l select-pane -R |
| 77 | +bind-key j select-pane -D |
| 78 | +bind-key k select-pane -U |
| 79 | +bind-key tab select-pane -t :.+ |
| 80 | +bind-key btab select-pane -t :.- |
| 81 | + |
| 82 | +# Synchronize panes |
| 83 | +bind-key * set-window-option synchronize-pane |
| 84 | + |
| 85 | +# Reload ~/.tmux.conf |
| 86 | +bind-key R source-file ~/.tmux.conf \; display-message "Reloaded!" |
| 87 | + |
| 88 | +# copy-mode |
| 89 | +bind-key -t vi-copy 'v' begin-selection |
| 90 | +bind-key -t vi-copy 'y' copy-pipe "pbcopy" |
| 91 | + |
| 92 | +# Capture pane and open in Vim |
| 93 | +bind-key C-c run 'tmux capture-pane -S -102400 -p > /tmp/tmux-capture.txt'\;\ |
| 94 | + new-window "view /tmp/tmux-capture.txt" |
| 95 | +bind-key M-c run "screencapture -l$(osascript -e 'tell app \"iTerm\" to id of window 1') -x -o -P /tmp/$(date +%Y%m%d-%H%M%S).png" |
| 96 | + |
| 97 | +# Notes |
| 98 | +bind-key C-n if-shell "tmux select-window -t NOTES" "" \ |
| 99 | + "new-window -n NOTES 'bash -i ~/gdrive/sync/notes/list'" |
| 100 | + |
| 101 | +# ------------------------------------------------------------------- |
| 102 | +# Decoration (256-color) |
| 103 | +# ------------------------------------------------------------------- |
| 104 | +set-option -g status-justify left |
| 105 | +set-option -g status-left '#[bg=colour72] #[bg=colour237] #[bg=colour236] #[bg=colour235]#[fg=colour185] #h #[bg=colour236] ' |
| 106 | +set-option -g status-left-length 16 |
| 107 | +set-option -g status-bg colour237 |
| 108 | +set-option -g status-right '#[bg=colour236] #[bg=colour235]#[fg=colour185] #(date "+%a %b %d %H:%M") #[bg=colour236] #[bg=colour237] #[bg=colour72] ' |
| 109 | +set-option -g status-interval 60 |
| 110 | + |
| 111 | +set-option -g pane-active-border-fg colour240 |
| 112 | +set-option -g pane-border-fg colour238 |
| 113 | + |
| 114 | +set-window-option -g window-status-format '#[bg=colour238]#[fg=colour107] #I #[bg=colour239]#[fg=colour110] #[bg=colour240]#W#[bg=colour239]#[fg=colour195]#F#[bg=colour238] ' |
| 115 | +set-window-option -g window-status-current-format '#[bg=colour236]#[fg=colour215] #I #[bg=colour235]#[fg=colour167] #[bg=colour234]#W#[bg=colour235]#[fg=colour195]#F#[bg=colour236] ' |
| 116 | + |
| 117 | +# ------------------------------------------------------------------- |
| 118 | +# fzf integration |
| 119 | +# ------------------------------------------------------------------- |
| 120 | +# Tmux completion |
| 121 | +bind-key -n 'M-t' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(tmuxwords.rb --all --scroll 1000 --min 5 | fzf --multi | paste -sd\\ -)\"'" |
| 122 | + |
| 123 | +# fzf-locate (all) |
| 124 | +bind-key -n 'M-`' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate / | fzf -m | paste -sd\\ -)\"'" |
0 commit comments