Updated tmux config
[dotfiles] / .tmux.conf
1 # https://leanpub.com/the-tao-of-tmux/read
2
3 # Escape codes for status bars and titles
4 # #H Hostname of local host
5 # #F Current window flag
6 # #I Current window index
7 # #P Current pane index
8 # #S Session name
9 # #T Current window title
10 # #W Current window name
11
12 # %h %d %Y - date in the [Mon DD YYYY] format
13 # %l:%M %p - time in the [HH:MM AM/PM] format
14
15
16 #------------------------------------------------------------------------------
17 # SETTINGS
18 #------------------------------------------------------------------------------
19
20 # Ensure color rendered properly?
21 # set -g default-terminal "screen-256color"
22 #set -g default-terminal "tmux-256color"
23
24 # ???
25 #set-option -ga terminal-overrides ",xterm-256color:Tc"
26
27 # Allow mouse to select windows
28 # set -g mouse on
29
30 # utf8 support? seems outdated?
31 #set-window-option -g utf8 on
32
33 # for being able to send one input to all panes
34 # synchronize-panes on # off
35
36 # set the prefix
37 set -g prefix C-b
38 unbind C-a
39 bind C-b send-prefix
40
41 # Sane scrolling ???
42 # set -g terminal-overrides 'xterm*:smcup@:rmcup@'
43
44 # update window number when one of them is deleted
45 set -g renumber-windows on
46
47 # Not renaming windows ???
48 # set -g allow-rename off
49
50 # begin index count to 1, not 0
51 set -g base-index 1
52
53 # ???
54 set -gs default-terminal screen-256color
55
56 # Set the time in milliseconds for which tmux waits after an escape is input
57 # to determine if it is part of a function or meta key sequences
58 set -s escape-time 20
59
60
61 #------------------------------------------------------------------------------
62 # STATUSBAR
63 #------------------------------------------------------------------------------
64
65 set -g status-position bottom
66 set -g status-style bg=black
67
68 set -g status-left ""
69 set -g status-right ""
70
71 # print the prefix if prefix pressed
72 set -ga status-right " #{?client_prefix, #[bright]#{prefix}#[nobright] ,}"
73
74 set -ga status-right ' #(echo \#"{last_exit_status_#{pane_id}}") '
75 #set -ga status-right ' #(cd #{pane_current_path} && sh -c "print -P %%~") '
76
77 # print the current git branch
78 # set -ga status-right '#(head="$(git -C #{pane_current_path} rev-parse --abbrev-ref HEAD 2>/dev/null)" && echo " $head ")'
79 set -ga status-right " [#H:#S] #[fg=yellow,dim] %d-%m %H:%M"
80 set -g status-right-length 200
81
82 # Left, display host and session name
83 #set -ga status-left " [#H:#S]"
84 #set -g status-left-length 50
85
86 # Window title in red if there is something
87 set -gw window-status-activity-style fg=brightred
88 set -gw window-status-bell-style fg=brightcyan
89
90 # 1 space between each window
91 set -gw window-status-separator ' '
92
93 # Inactive windows in status bar
94 set-window-option -g window-status-format '#[fg=cyan,dim]#I#[fg=blue,dim]:#[default,dim]#W'
95
96 set-window-option -g window-status-current-format '#[bg=black,fg=cyan,bold]#I#[bg=black,fg=red]:#[bg=black,fg=yellow]#W#[fg=dim]'
97
98 # put useful info in the window status bar lol
99 # set-option -g set-titles on
100 # set-option -g set-titles-string '#H:#S.#I.#P #W #T'
101
102
103 #------------------------------------------------------------------------------
104 # PANES
105 #------------------------------------------------------------------------------
106
107 # pane border style
108 set -gw pane-active-border-style fg=brightyellow
109
110 # pane index starts at 1, not 0
111 set -gw pane-base-index 1
112
113 # do you want to see something pane related?
114 #set -gw pane-border-status top
115
116 # what do you want to see pane related?
117 #set -gw pane-border-format ' #{pane_current_command} '
118
119
120
121 #------------------------------------------------------------------------------
122 # BINDINGS
123 #------------------------------------------------------------------------------
124
125 # map Fns to Windows
126 bind -n F1 select-window -t :1
127 bind -n F2 select-window -t :2
128 bind -n F3 select-window -t :3
129 bind -n F4 select-window -t :4
130 bind -n F5 select-window -t :5
131 bind -n F6 select-window -t :6
132 bind -n F7 select-window -t :7
133 bind -n F8 select-window -t :8
134 bind -n F9 select-window -t :9
135 bind -n F10 select-window -t :10
136 bind -n F11 select-window -t :11
137 bind -n F12 select-window -t :12
138 bind -n S-F1 select-window -t :13
139 bind -n S-F2 select-window -t :14
140 bind -n S-F3 select-window -t :15
141 bind -n S-F4 select-window -t :16
142 bind -n S-F5 select-window -t :17
143 bind -n S-F6 select-window -t :18
144 bind -n S-F7 select-window -t :19
145 bind -n S-F8 select-window -t :20
146
147
148 # clear screen then clear history
149 # bind -n <-- no need to send the prefix
150 bind -n C-l send-keys C-l \; run-shell "sleep 0.3" \; clear-history
151
152
153 # Intuitive splitting
154 # Split into panes, but stay in the current path
155 bind | split-window -h -c '#{pane_current_path}'
156 bind - split-window -v -c '#{pane_current_path}'
157 bind _ split-window -v -c '#{pane_current_path}'
158
159
160 # bind kill-session to C-a k
161 bind k kill-session
162
163
164 #------------------------------------------------------------------------------
165 # HOOKS
166 #------------------------------------------------------------------------------
167
168 # To refresh status bar after selecting a pane or when there is an alert
169 set-hook -g after-select-pane "refresh-client -S"
170 set-hook -g alert-activity "refresh-client -S"
171
172
173
174 #------------------------------------------------------------------------------
175 # ACTIVITY MONITORING
176 #------------------------------------------------------------------------------
177
178 # Monitor and alert whenever the output changes
179 set -gw monitor-activity on
180 set -gw activity-action none
181 set -g visual-activity on
182
183
184
185
186 #------------------------------------------------------------------------------
187 # SOME KATA
188 #------------------------------------------------------------------------------
189
190 #reload this file
191 bind M-r source-file ~/.tmux.conf \; display-message "tmux configuration reloaded!"
192
193 # launch ssh in another window
194 bind M-s command-prompt -p "ssh" "new-window -n ssh:%1 'exec ssh %1'"
195
196 # call man of command on another panel
197 bind M-m command-prompt -p "man" "split-window -h 'exec man %1'"
198
199 # open irc in another window
200 bind M-i new-window -n irc \; \
201 send-keys -t :irc 'irssi -c irc.freenode.net -n patricknsukami -w patrick/nsukami' C-m \; \
202 select-window -t :irc
203
204 # open postgresql on another window
205 bind M-p new-window -n psql \; \
206 send-keys -t :psql 'psql -U postgres -W -h localhost' C-m \; \
207 select-window -t :psql
208
209 #
210 # bind M-v new-window -n vlc -c /home/nsukami/Musique \; \
211 # send-keys -t :vlc 'vlc --intf rc playlist' C-m \; \
212 # split-window -h -t :vlc -c /home/nsukami/Musique \; \
213 # send-keys -t :vlc.1 "find . -maxdepth 1 -type f -printf '%f\n'" C-m \; \
214
215
216 # tell vlc to play something
217 bind M-v command-prompt -p "vlc " "new-window -n vlc -c /home/nsukami/Musique 'exec vlc --intf rc %1' \; \
218 split-window -h -p 30 -t :vlc -c /home/nsukami/Musique \; \
219 send-keys -t :vlc.1 'ls' C-m \; \
220 send-key -t :vlc.0 'playlist' C-m \; \
221 select-pane -t :vlc.0 \; \
222 last-window -t : "
223
224
225
226 #------------------------------------------------------------------------------
227 # OFTEN USED SESSIONS
228 #------------------------------------------------------------------------------
229
230 bind F source-file ~/.tmux/etudes.conf
231 bind G source-file ~/.tmux/events.conf
232 bind J source-file ~/.tmux/jalv2.conf