-
Notifications
You must be signed in to change notification settings - Fork 2
/
tmux.conf
151 lines (117 loc) · 5.34 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
# -------------------- CONFIG ---------------------------
# Unbind ALL keybindings whilst REBINDING defaults
# run-shell '\
# export f=$(mktemp) \
# && tmux -f /dev/null -L temp start-server \; list-keys > $f \
# && tmux unbind -a \; source-file $f'
set -g default-command /bin/zsh
set -g default-shell /bin/zsh
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
set -g base-index 1 # Start window numbering from 1 instead of 0
set -g renumber-windows on # Renumber as windows are created/destroyed
# switch window with h & l (VIM-like navigation)
unbind n
unbind p
bind l next-window
bind h previous-window
# Resize the current pane using Alt + direction
bind -n M-k resize-pane -U 5
bind -n M-j resize-pane -D 5
bind -n M-h resize-pane -L 5
bind -n M-l resize-pane -R 5
# don't rename windows automatically
set-option -g allow-rename off
# Smart pane switching with awareness of Vim splits.
# Original: https://github.com/christoomey/vim-tmux-navigator
# Neovim plugin: https://github.com/aserowy/tmux.nvim#navigation
# Lunarvim: https://github.com/LunarVim/LunarVim/issues/2745#issuecomment-1165905419
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|[ln]?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }
bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L'
bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D'
bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U'
bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R'
# Swap windows (move tabs) with Ctrl+Shift+arrows
bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
bind-key -n C-S-Right swap-window -t +1\; select-window -t +1
# split panes using | and - and always use same directory
unbind '"'
unbind %
unbind c
bind n new-window -c "#{pane_current_path}"
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -l 20% -c "#{pane_current_path}"
bind c split-window -v -c "#{pane_current_path}" \; send-keys "git commit" Enter
# Break and join windows
bind b break-pane -d
bind-key j command-prompt -p "join pane from: " "join-pane -h -s '%%'"
# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf \; display-message "tmux config reloaded!"
# use mouse for navigating
set -g mouse on
# No delay for escape key:
set -sg escape-time 0
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Use vim keybindings in copy mode
setw -g mode-keys vi
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy"
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "pbcopy"
unbind -T copy-mode-vi Space
bind -T copy-mode-vi Space send -X jump-again
bind-key -T copy-mode-vi 0 send -X back-to-indentation
bind y run 'tmux save-buffer - | pbcopy '
bind C-y run 'tmux save-buffer - | pbcopy '
# ------------------- UI --------------------------------
# loud or quiet?
set-option -g visual-activity off
set-option -g visual-bell off
set-option -g visual-silence off
set-window-option -g monitor-activity off
set-option -g bell-action none
TMUX_STATUS_BG_COLOR="#1E2030"
TMUX_STATUS_TEXT_COLOR="#abb2bf"
# TMUX_PANE_BORDER_COLOR="#1B2026"
# TMUX_WINDOW_INACTIVE_TEXT_COLOR="#727A84"
# TMUX_WINDOW_INACTIVE_BG_COLOR="#1F2126"
# TMUX_WINDOW_ACTIVE_TEXT_COLOR="colour250"
# TMUX_WINDOW_ACTIVE_BG_COLOR="black"
# statusbar at bottom:
set -g status-style bg=$TMUX_STATUS_BG_COLOR,fg=$TMUX_STATUS_TEXT_COLOR
set -g status-position bottom
set -g status-justify left
set -g status-left-style fg=white,bg=black
set -g status-left-length 20
set -g status-right-length 50
# Show current session name
set-window-option -g status-left " #S "
# Use the xterm-256color terminal
# set -g default-terminal "xterm-256color-italic"
set -g default-terminal "xterm-256color"
# Apply Tc (true color)
set-option -ga terminal-overrides ",xterm-256color:Tc"
# set -g pane-border-style fg=$TMUX_PANE_BORDER_COLOR
# set -g pane-active-border-style fg=blue,bg=default
set -g window-status-current-style bg=blue,fg=black
set -g window-status-current-format ' #I: #W ' # Index & Window name
set -g window-status-format ' #I: #W '
# set inactive/active window styles
# set -g window-style fg=$TMUX_WINDOW_ACTIVE_TEXT_COLOR,bg=$TMUX_WINDOW_ACTIVE_BG_COLOR
# set -g window-active-style fg=$TMUX_WINDOW_ACTIVE_TEXT_COLOR,bg=$TMUX_WINDOW_ACTIVE_BG_COLOR
# ----------------- PLUGINS -----------------------------
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect' # Bring back tmux sessions after computer restart
set -g @plugin 'tmux-plugins/tmux-continuum' # Continuously save tmux sessions
set -g status-right " #(cd #{pane_current_path}; git branch --show-current) "
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'