-
Notifications
You must be signed in to change notification settings - Fork 2
/
tmux.conf
152 lines (116 loc) · 5.38 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
################################################################################
# GLOBAL CONFIG
################################################################################
# Remember our roots: bind prefix to CTRL-a like GNU Screen
set -g prefix C-a
unbind C-b
# Type C-a C-a to send a literal ^A
bind C-a send-prefix
# Reduce tmux delay to avoid vim issues
set -s escape-time 1
# Increase the repeat-time a bit from 500ms
set -g repeat-time 750
# Start numbering windows and panes at 1 instead of 0
#set -g base-index 1
#setw -g pane-base-index 1
# Now we can do italics and 24-bit color (truecolor)
# https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",*256color:RGB"
# Up the pane history from 2000
set -g history-limit 100000
# Prevent the shell from renaming our windows
set -g allow-rename off
# If smaller client is looking at a different window on same session allow for different sizes
set -g aggressive-resize on
# On OS X, use the reattach-to-user-namespace wrapper in order to retain
# access to the system clipboard within tmux sessions...
# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
set-option -g default-command 'command -v reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace -l "$SHELL" || exec "$SHELL"'
set -g automatic-rename on
################################################################################
# CUSTOM BINDINGS
################################################################################
# Reload tmux config
bind r source-file ~/.tmux.conf \; display "tmux config reloaded!"
# Intuitive window splitting keys
# Note: to tmux, `-v` means "create a new pane below this one"
# and `-h` means "create a new pane next to the existing one"
bind | split-window -h
bind - split-window -v
# Vim-style movement between panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# ...and windows (note: `-r` means "repeatable")
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Use C-w to toggle between last two used windows
bind -r C-w last-window
# toggling panes is C-a ;
# Smart pane switching with awareness of vim splits
# Requires https://github.com/christoomey/vim-tmux-navigator
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim|ssh|mosh?)(diff)?$"'
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
# bind -n C-\\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# Pane resizing
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Maximize pane vertically
bind -r m run-shell -b "~/.dotfiles/tmux_scripts/maximize_pane_vertically.sh"
# Make pane layout switch repeatable
bind -r Space next-layout
# Mouse does fancy things in latest Tmux (2.1)
set -gq mouse on
set -gq mode-mouse on
set -gq mouse-resize-pane on
set -gq mouse-select-pane on
set -gq mouse-select-window on
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Change copy / paste bindings to work like Vim
bind Escape copy-mode
bind p paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# New Tmux 2.1 feature to scroll up on PgUp (or ctrl-u) if not in full-screen app
# (a.k.a., using "alternate screen").
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage"
bind-key -T root C-u if-shell -F "#{alternate_on}" "send-keys C-u" "copy-mode -e; send-keys C-u"
bind-key -T copy-mode-vi PPage send-keys -X page-up
bind-key -T copy-mode-vi NPage send-keys -X page-down
# ...and do a similar thing for mouse-wheel scrolling...
bind-key -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
bind-key -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
bind-key -T copy-mode-vi WheelUpPane send-keys -X halfpage-up
bind-key -T copy-mode-vi WheelDownPane send-keys -X halfpage-down
# Toggle sync to all panes
bind s setw synchronize-panes
################################################################################
# COLORS / LAYOUT
################################################################################
set -g status-fg white
set -g status-bg black
set -g window-status-style "fg=white,bg=black,dim"
set -g window-status-current-style "fg=black,bg=green,dim"
set -g pane-border-style "fg=green,bg=black"
set -g pane-active-border-style "fg=white,bg=green"
set -g message-style "fg=white,bg=black,bright"
# Status line
set -g status-left-length 30
set -g status-left "#[bg=black]#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
set -g status-right-length 55
set -g status-right "#[bg=black]#[fg=red]#(~/.dotfiles/zelda-battery-tmux.sh) #[fg=green]#h #[fg=cyan]%d%b%Y %l:%M%p (#(TZ=UTC date -u +%%H:%%M) UTC)"
set -g status-justify centre
set -g monitor-activity on
set -g visual-activity on
set -g status-interval 10