-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
154 lines (122 loc) · 5.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
142
143
144
145
146
147
148
149
150
151
152
153
154
# =====useful references=====
#
# http://tmuxp.readthedocs.io/en/latest/about_tmux.html
# http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/
# http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
# http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/
# http://jasonwryan.com/blog/2011/06/07/copy-and-paste-in-tmux/
# https://github.com/christoomey/vim-tmux-navigator
# =====basic bindings=====
#
# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf
# change prefix - trigger from C-b to C-q, it is indeed handier
unbind b
set-option -g prefix C-q
# use alt + q to send prefix to inner tmux
bind-key -n M-q send-prefix \; send-prefix -2
# default window creation opens window in dir tmux was started
bind-key c new-window
# prefix + q opens window in same current path
# use q since its easy to type after prefix
bind-key q new-window -c "#{pane_current_path}"
# use bash - this allows us to use our command prompt from bashrc
set-option -g default-command bash
# =====technical section=====
setw -g aggressive-resize on
# set scrollback history to 10000 (10k)
set -g history-limit 10000
set -s set-clipboard off
# Toggle mouse on with ^B m
bind m \
set -g mouse on \;\
display 'Mouse: ON'
# Toggle mouse off with ^B M
bind M \
set -g mouse off \;\
display 'Mouse: OFF'
# =====vim section=====
# Make changing mode in vim much smoother
set -s escape-time 0
# use vi keybindings
setw -g mode-keys vi
# copy paste vim style
# https://github.com/tmux/tmux/issues/592
bind-key -Tcopy-mode-vi 'v' send-keys -X begin-selection
bind-key -Tcopy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
bind-key -Tcopy-mode-vi c-c send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
bind-key -Tcopy-mode-vi Escape send-keys -X cancel
bind-key -Tcopy-mode-vi c-v send-keys -X rectangle-toggle
# make similar bindings to window change as that of panes
bind h previous-window
bind l next-window
# use k and j to split windows
bind k split-window -h -c "#{pane_current_path}"
bind j split-window -v -c "#{pane_current_path}"
# bind escape key to copy-mode
unbind [
bind-key Escape copy-mode
# I use control-stuff for pane switching because I do this all the time and I want
# to avoid having to use prefix.
# However this overrides C-l that is usually mapped to clear screen
# 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)?$'"
# Below is not a convenient mapping by default.
# I have mapped super-h-j-k-l to C-F1-F2-F3-F4 (see alacritty.yml)
bind-key -n C-F1 if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-F2 if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-F3 if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-F4 if-shell "$is_vim" "send-keys C-l" "select-pane -R"
# resize panes using super-H-J-K-L (see alacritty.yml)
bind-key -n S-F1 resize-pane -L 8
bind-key -n S-F2 resize-pane -D 8
bind-key -n S-F3 resize-pane -U 8
bind-key -n S-F4 resize-pane -R 8
# use alt-stuff to navigate panes in inner tmux
bind-key -n M-h send-prefix \; send-keys C-F1
bind-key -n M-j send-prefix \; send-keys C-F2
bind-key -n M-k send-prefix \; send-keys C-F3
bind-key -n M-l send-prefix \; send-keys C-F4
# use alt-shift-stuff to resize panes in inner tmux
bind-key -n M-H send-prefix \; send-keys S-F1
bind-key -n M-J send-prefix \; send-keys S-F2
bind-key -n M-K send-prefix \; send-keys S-F3
bind-key -n M-L send-prefix \; send-keys S-F4
# window moving
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
set -g @shell_mode 'vi'
# =====theme section=====
# blue background
bb="#[fg=colour234,bg=colour$HOST_COLOUR]"
# blue foreground
bf="#[fg=colour$HOST_COLOUR,bg=colour234]"
set -g status-position bottom
set -g status-style fg="colour$HOST_COLOUR",bg=colour234
set -g window-status-activity-style bold
set -g pane-border-style fg=colour245
set -g pane-active-border-style fg=colour39
set -g message-style fg=colour202,bg=colour234
set -g status-left " #[fg=colour$HOST_COLOUR,bg=colour235]#(whoami) #H "
set -g window-status-format "#[fg=colour$HOST_COLOUR,bg=colour234] #W "
set -g window-status-current-format "#[reverse]#I#[noreverse] #[bold]#W #[default] "
set -g status-interval 5
set -g status-right "$bf$bb $bf#(memusage) $bf$bb $bf#(mydate)#[default]"
set -g status-right-length 60
set -g status-left-length 120
# tc + italics please
# If error about unsupported terminal:
# curl https://gist.githubusercontent.com/sadsfae/0b4dd18670639f7dce941a1b2a9e4e9e/raw/908b48e6b6370da0568be8d138966c60240a50dd/xterm-256color-italic.terminfo > xterm-256color-italic
# tic xterm-256color-italic
# set -g default-terminal "xterm-256color-italic"
# set -g default-terminal "xterm-256color-italic"
set -g default-terminal "xterm-256color-italic"
# =====plugin section=====
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-yank'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'