-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.tmux.conf
141 lines (109 loc) · 4.25 KB
/
.tmux.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Hierarchy:
# Server
# ㄴSession
# ㄴWindow
# ㄴPane
# Options:
# - Session options (set-option [-g])
# - Window options (set-window-option [-g])
# -------------------------------------------------------------------
# Session options
# -------------------------------------------------------------------
# Change bind key to ctrl-a
unbind-key c-b
set-option -g prefix c-a
# Index starts from 1
set-option -g base-index 1
# otherwise tmuxinator doesnt work
set-option -g pane-base-index 1
# Renumber windows when a window is closed
set-option -g renumber-windows on
# Prevent automatic window renaming
set-option -g allow-rename off
# History
set-option -g history-limit 102400
# Repeat time limit (ms)
set-option -g repeat-time 500
# 256-color terminal
set-option -g default-terminal "tmux-256color"
set -as terminal-overrides ',xterm*:sitm=\E[3m'
# true color terminal
set-option -ga terminal-overrides ",xterm-256color:Tc"
# Key binding in the status line (bind-key :)
set-option -g status-keys emacs
# Mouse
set-option -g mouse on
# Escape delay
set -s escape-time 0
# -------------------------------------------------------------------
# Window options
# -------------------------------------------------------------------
# Copy-mode
set-window-option -g mode-keys vi
set-option -g focus-events on
# -------------------------------------------------------------------
# Key bindings
# -------------------------------------------------------------------
# prefix c
bind-key c new-window -c "#{pane_current_path}"
# prefix ctrl-a
bind-key c-a last-window
# prefix a
bind-key a send-prefix
# prefix |
bind-key | split-window -h -c "#{pane_current_path}"
# prefix -
bind-key - split-window -c "#{pane_current_path}"
# Moving windows
bind-key -r > swap-window -t :+
bind-key -r < swap-window -t :-
# Back and forth
bind-key bspace previous-window
bind-key space next-window
bind-key / next-layout # Overridden
bind-key v select-layout main-vertical
# Pane-movement
bind-key h select-pane -L
bind-key l select-pane -R
bind-key j select-pane -D
bind-key k select-pane -U
bind-key tab select-pane -t :.+
bind-key btab select-pane -t :.-
# Synchronize panes
bind-key * set-window-option synchronize-pane
# Reload ~/.tmux.conf
bind-key R source-file ~/.tmux.conf \; display-message "Reloaded!"
# copy-mode
bind-key -Tcopy-mode-vi 'v' send -X begin-selection
bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# Capture pane and open in Vim
bind-key C-c run 'tmux capture-pane -S -102400 -p > /tmp/tmux-capture.txt'\;\
new-window "view /tmp/tmux-capture.txt"
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"
# Notes
bind-key C-n if-shell "tmux select-window -t NOTES" "" \
"new-window -n NOTES 'bash -i ~/gdrive/sync/notes/list'"
# -------------------------------------------------------------------
# fzf integration
# -------------------------------------------------------------------
# Tmux completion
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\\ -)\"'"
# fzf-locate (all)
bind-key -n 'M-`' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate / | fzf -m | paste -sd\\ -)\"'"
# -------------------------------------------------------------------
# tmuxline theme
# -------------------------------------------------------------------
source-file ~/.dotfiles/tmux/tmuxline
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" "send-keys 'C-h'" "select-pane -L"
bind-key -n 'C-j' if-shell "$is_vim" "send-keys 'C-j'" "select-pane -D"
bind-key -n 'C-k' if-shell "$is_vim" "send-keys 'C-k'" "select-pane -U"
bind-key -n 'C-l' if-shell "$is_vim" "send-keys 'C-l'" "select-pane -R"
bind-key -n 'C-\' if-shell "$is_vim" "send-keys 'C-\'" "select-pane -l"
bind 'C-l' send-keys 'C-l'
# MacOS Sierra Clipboard fixes, needs reattach-to-user-namespace
#set -g default-shell $SHELL
#set -g default-command "reattach-to-user-namespace -l ${SHELL}"