-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtmux.conf
167 lines (127 loc) · 5.86 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
###########################
# Key Bindings
###########################
# tmux prefix
unbind C-b
set -g prefix C-Space
# force a reload of the config file
bind r source-file ~/.tmux.conf \; display "~/.tmux.conf reloaded!"
# copying/pasting
set -g default-shell $SHELL
set -g default-command "reattach-to-user-namespace -l ${SHELL}"
set-option -g display-time 1500
# # Seamless navigation using vim-tmux-navigator (github 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"
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'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
# Restore clear screen keybind mapped over by tmux-navigator
bind C-l send-keys C-l
# More intuitive pane splitting key-bindings, open all in current path
bind - split-window -v -c "#{pane_current_path}"
bind \\ split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
bind C-Space next-layout
# Easy resizing of panes with fine and coarse adjustment
# If any of these aren't working, look at
# System Preferences -> Keyboard -> Shortcuts
# for any global shortcuts using ^ (probably Mission Control)
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
bind -n C-Left resize-pane -L 10
bind -n C-Right resize-pane -R 10
bind -n C-Down resize-pane -D 5
bind -n C-Up resize-pane -U 5
bind-key b break-pane -d
bind-key C-j choose-tree
# prefix-g opens a gitsh window
bind-key C-g split-window -h -c "#{pane_current_path}" "gitsh"
# bind-key C-g split-window -h -c "#{pane_current_path}" "cloud-box-gitsh"
# # unbind g
# unbind C-o
# # bind-key C-c split-window -h -p 50 "rails c"
# bind-key C-c split-window -h -p 50 -c "#{pane_current_path}" "bin/rails console"
# # bind-key C-c split-window -h -c "#{pane_current_path}" "bin/rails console"
# Use vim keybindings in copy mode
setw -g mode-keys vi
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
unbind -T copy-mode-vi Space
bind -T copy-mode-vi Space send -X jump-again
bind-key -T copy-mode-vi 0 send -X back-to-indentation
bind y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '
bind C-y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '
# easily find sessions and switch
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
# break out a new session
bind-key C-b send-keys 'tat && exit' 'C-m'
# kill the current session
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
# Prompted join-pane
bind-key j command-prompt -p "join pane from: " "join-pane -h -s '%%'"
# Easily swap a pane (targeted by pane number) with the current pane
bind-key s display-panes\; command-prompt -p "pane #: " "swap-pane -t '%%'"
##########################
# Configuration
###########################
# use 256 term for pretty colors
set -g default-terminal "screen-256color"
# set -g terminal-overrides ',xterm-256color:Tc'
# set -g default-terminal "tmux-256color"
# set -as terminal-overrides ',xterm*:sitm=\E[3m'
# increase scroll-back history
set -g history-limit 2000
# use vim key bindings
setw -g mode-keys vi
set-option -g status-keys "emacs"
# decrease command delay (increases vim responsiveness)
set -sg escape-time 1
# increase repeat time for repeatable commands
set -g repeat-time 1000
# start window index at 1
set -g base-index 1
# start pane index at 1
setw -g pane-base-index 1
# re-number windows when one is closed
set -g renumber-windows on
###########################
# Status Bar
###########################
# set refresh interval for status bar
set -g status-interval 30
# show session, window, pane in left status bar
set -g status-left-length 40
set -g status-left '#[fg=green]#S#[fg=blue] #I:#P#[default] '
# show hostname, date, time, and battery in right status bar
set -g status-right-length 100
set-option -g status-right '#[fg=green]#H#[default] %Y-%m-%d %H:%M #(battery -tpe)'
# set-option -g status-right '#[fg=green]#H#[default] %Y-%m-%d %H:%M'
###########################
# Colors
###########################
# color status bar
set -g status-style fg=white,bg=colour235
# highlight current window
set -g window-status-current-style fg=black,bg=green
# set color of active pane
set -g pane-border-style fg=colour235,bg=black
set -g pane-active-border-style fg=green,bg=black