-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
159 lines (129 loc) · 6.37 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
# set the current tmux version (use this variable on if-shell commands)
# run-shell "tmux set-environment -g TMUX_VERSION $(tmux -V | cut -c 6-)"
run-shell "tmux set-environment -g TMUX_VERSION $(tmux -V | cut -c 6- | tr -d '[A-Z][a-z]')" # remove alphabets e.g 2.9a ==> 2.9 only
# enable 256 color terminal
# http://blog.sanctum.geek.nz/256-colour-terminals/
set-option -g default-terminal "screen-256color"
# change prefix key (avoid ctrl+a conflicts with gnu screen, emacs)
unbind-key C-Space
set-option -g prefix C-Space
#history size
set-option -g history-limit 10000
# Disable escape key delay
set -sg escape-time 0
#-------- Keybinding (Vim Style) {{{
#------------------------------------------------------
# vim keys in command prompt
set-option -g status-keys vi
# select panes
bind-key k select-pane -U
bind-key h select-pane -L
bind-key j select-pane -D
bind-key l select-pane -R
# cycle windows/panes (no prefix)
bind-key -n M-k select-pane -t :.- # prev pane (Alt+k conflicts with weechat)
bind-key -n M-o select-pane -t :.+ \; resize-pane -Z # next pane in zoomed mode
bind-key -n M-j select-pane -t :.+ # next pane
bind-key -n M-h select-window -t :- # previous window
bind-key -n M-l select-window -t :+ # next window
# cycle sessions
bind-key -r s switch-client -n
bind-key -r S choose-session
# resize panes
bind-key -r J resize-pane -D 1
bind-key -r K resize-pane -U 1
bind-key -r H resize-pane -L 1
bind-key -r L resize-pane -R 1
# split pane (tmux 1.9+)
bind-key \\ split-window -h -c "#{pane_current_path}" # vertical split (default prefix-%)
bind-key - split-window -v -c "#{pane_current_path}" # horizontal split (default prefix-")
# split full window (tmux 2.3+)
bind-key | split-window -fh -c "#{pane_current_path}"
bind-key _ split-window -fv -c "#{pane_current_path}"
#-------- Copy Mode (Vim Style) {{{
#------------------------------------------------------
# This section of hotkeys mainly work in copy mode and no where else
# vim keys in copy and choose mode
set-window-option -g mode-keys vi
# copying selection vim style
# http://jasonwryan.com/blog/2011/06/07/copy-and-paste-in-tmux/
# https://github.com/myfreeweb/dotfiles/blob/master/tmux.conf
bind-key Escape copy-mode # default key: prefix [
bind-key p paste-buffer # default key: prefix ] ; interactively clipboard history key: prefix =
bind-key + delete-buffer \; display-message "Deleted current Tmux Clipboard History"
# send to tmux clipboard or system clipboard
bind-key < run-shell "tmux set-buffer -- \"$(xsel -o -b)\"" \; display-message "copy to tmux clipboard"
bind-key > run-shell 'tmux show-buffer | xsel -i -b' \; display-message "copy to system clipboard"
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi V send-keys -X select-line
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T choice-mode-vi h send-keys -X tree-collapse
bind-key -T choice-mode-vi l send-keys -X tree-expand
bind-key -T choice-mode-vi H send-keys -X tree-collapse-all
bind-key -T choice-mode-vi L send-keys -X tree-expand-all
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe "xclip -in -selection clipboard"
bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -in -selection clipboard"
# use vim as copy mode
#bind-key v capture-pane \; save-buffer /tmp/tmux-buffer \; new-window -n "vim-copymode" '$SHELL -c "vim /tmp/tmux-buffer"'
# toggle mouse mode (tmux 2.1 or higher)
# https://www.reddit.com/r/tmux/comments/3paqoi/tmux_21_has_been_released/cw552qd
bind-key m set-option -g -q mouse on \; display-message 'Mouse: ON'
bind-key M set-option -g -q mouse off \; display-message 'Mouse: OFF'
# enable PageUp/Down as copy mode
# if in ncurses app (vim,nano ..etc) then functions as normal
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage"
# swap panes
bind-key W choose-tree -Zw "swap-window -t '%%'"
bind-key P choose-tree -Zw "swap-pane t '%%'"
bind-key C-p choose-tree -Zw "move-pane -t '%%'"
# refresh the status bar every 1 second.
set-option -g status-interval 1
# command/message line colors
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.9" | bc)" = 1 ]' \
'set-option -g message-fg white; \
set-option -g message-bg black; \
set-option -g message-attr bright'
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.9" | bc)" = 1 ]' \
'set-option -g message-style fg=white,bg=black,bright'
# Symbol Meaning ================================
# * Denotes the current window.
# - Marks the last window (previously selected).
# # Window is monitored and activity has been detected.
# ! A bell has occurred in the window.
# ~ The window has been silent for the monitor-silence interval.
# M The window contains the marked pane.
# Z The window's active pane is zoomed.
# monitor changes on non-focus window (activity symbol = #)
# (e.g 1:zsh 2:zsh 3:torr# 4:im- 5:chat# 6:fm# 7:conf*)
set-window-option -g monitor-activity on
set-window-option -g window-status-bell-style 'fg=black,bg=colour5,bright'
# statusbar colors
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.9" | bc)" = 1 ]' \
'set-option -g status-fg white; \
set-option -g status-bg black; \
set-option -g status-attr default'
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.9" | bc)" = 1 ]' \
'set-option -g status-style fg=white,bg=black,default'
# window title colors; non active
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.9" | bc)" = 1 ]' \
'set-window-option -g window-status-fg cyan; \
set-window-option -g window-status-bg default; \
set-window-option -g window-status-attr dim'
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.9" | bc)" = 1 ]' \
'set-window-option -g window-status-style fg=cyan,bg=default,dim'
# window title colors; active
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.9" | bc)" = 1 ]' \
'set-window-option -g window-status-current-fg white; \
set-window-option -g window-status-current-bg red; \
set-window-option -g window-status-current-attr bright'
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.9" | bc)" = 1 ]' \
'set-window-option -g window-status-current-style fg=white,bg=red,bright'
#}}}
# LEFT SIDE {{{
set-option -g status-justify centre
set-option -g status-left-length 40
set-option -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
#}}}
# RIGHT SIDE {{{
# use "man date" to set the clock to your liking
set-option -g status-right "#[fg=blue]#(~/battery Discharging) | #[fg=cyan]%a %d/%m/%y %k:%M"