-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
110 lines (85 loc) · 3.65 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
# Tmux configuration based on anmonteiro's dotfile.
# See: https://github.com/anmonteiro/dotfiles
setw -g mode-keys vi
set -g status-keys vi
# Mouse support - set to on if you want to use the mouse
set-option -g mouse off
# Set the default terminal mode to 256color mode
# set -g default-terminal "screen-256color"
set -g default-terminal "tmux-256color"
set -as terminal-overrides ',xterm*:sitm=\E[3m'
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
# keybindings
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
unbind r
bind r \
source-file ~/.tmux.conf \;\
display 'Reloaded tmux config.'
# avoid confirmation prompts
bind-key & kill-window
bind-key x kill-pane
# start with window 1 (instead of 0)
set -g base-index 1
# start with pane 1
set -g pane-base-index 1
bind -n C-l send-keys -R \; clear-history \; send-keys C-l
set -g history-limit 131072
# set escape time to 10ms. The 500ms default is horrible for Vim
set -sg escape-time 0
bind c new-window -c "#{pane_current_path}"
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Lots taken from https://gist.github.com/spicycode/1229612
# Pane resizing
bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key H resize-pane -L 5
bind-key L resize-pane -R 5
bind-key M-j resize-pane -D
bind-key M-k resize-pane -U
bind-key M-h resize-pane -L
bind-key M-l resize-pane -R
# 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)?$'"
bind-key -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'select-pane -L'
bind-key -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'select-pane -D'
bind-key -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'select-pane -U'
bind-key -n 'M-l' if-shell "$is_vim" 'send-keys M-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 'M-h' select-pane -L
bind-key -T copy-mode-vi 'M-j' select-pane -D
bind-key -T copy-mode-vi 'M-k' select-pane -U
bind-key -T copy-mode-vi 'M-l' select-pane -R
bind-key -T copy-mode-vi 'M-\' select-pane -l
# Alt-n/p to switch windows
bind -n M-p previous-window
bind -n M-n next-window
# Copy mode to match Vim's
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-selection
# Update the seconds in the status bar
set-option -g status-interval 1
# Status bar theming
set -g status-bg colour10
set -g status-fg colour0
set -g window-status-current-style bold
set -g status-right-length 55
tm_date='%a %h %d'
tm_time='%H:%M:%S'
set -g status-right '#[fg=colour0]#[fg=colour10]#[bg=colour0] #(whoami) \
#[fg=colour10]#[bg=colour10]#\
[fg=default] '$tm_date' #[fg=colour75]#[fg=default]#[bg=colour75] '$tm_time' '
# bind C-j new-window -n "session-switcher" "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
# bind C-j display-popup -E "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
bind C-j display-popup -E "tmux list-sessions | sed -E 's/:.*$//' | fzf --reverse | xargs tmux switch-client -t"