-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux.conf
127 lines (97 loc) · 4.63 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
# ----------------------------------------------------------------------------j
# -- General
# -----------------------------------------------------------------------------
# Let nvim background override tmux's
set -ga terminal-overrides ",xterm-256color:Tc"
# Override prefix key
unbind C-b
set -g prefix C-g
bind C-g send-prefix
# See https://github.com/neovim/neovim/wiki/FAQ#esc-in-tmux-or-gnu-screen-is-delayed
set -sg escape-time 0
set -g mouse on
set -g history-limit 500000
# yazi image preview
set -g allow-passthrough on
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM
# -----------------------------------------------------------------------------
# -- Key bindings
# -----------------------------------------------------------------------------
# Unbind default key bindings, we're going to override
unbind "\$" # rename-session
unbind , # rename-window
unbind % # split-window -h
unbind '"' # split-window
unbind & # kill-window
unbind s # choose-tree
unbind w # choose-window
# Edit config and reload
bind C-e new-window -n 'dotfiles' -c "~/.dotfiles" "sh -c '\${EDITOR:-nvim} && tmux kill-window && tmux source ~/.tmux.conf'"
# Show man pages for tmux
bind C-m new-window -n 'man tmux' "sh -c 'man tmux && tmux kill-window'"
# Reload tmux config
bind C-r source-file ~/.tmux.conf \; display "source ~/.tmux.conf"
# Deploy dotter
bind C-d run-shell "~/.dotfiles/scripts/deploy-dotter.sh"
# Choose between session and windows
bind C-s choose-tree -Zs # choose-tree starts in a pane, -Z means to zoom the pane
bind C-w choose-tree -Zw
# Create new session
bind C-c command-prompt -I "new-session -s "
# Create new windows and panes in current directory
bind c new-window -c "#{pane_current_path}"
bind s split-window -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"
# Rename session and window
bind r command-prompt -I "#{window_name}" "rename-window '%%'"
bind R command-prompt -I "#{session_name}" "rename-session '%%'"
# Kill pane/window/session shortcuts
bind x kill-pane
bind X kill-window
bind C-x confirm-before -p "kill other windows? (y/n)" "kill-window -a"
bind Q confirm-before -p "kill-session #S? (y/n)" kill-session
# -----------------------------------------------------------------------------
# -- Display
# -----------------------------------------------------------------------------
set -g base-index 1 # start windows numbering at 1
setw -g pane-base-index 1 # make pane numbering consistent with windows
setw -g automatic-rename on # rename window to reflect current program
set -g renumber-windows on # renumber windows when a window is closed
set -g set-titles on # set terminal title
# -----------------------------------------------------------------------------
# -- Navigation and resize
# -----------------------------------------------------------------------------
# tmux-nvim-navigation
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
# navigation
bind -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
bind -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
bind -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
bind -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }
bind -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L'
bind -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D'
bind -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U'
bind -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R'
# resize-pane
bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 1'
bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 1'
bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 1'
bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 1'
bind -T copy-mode-vi M-h resize-pane -L 1
bind -T copy-mode-vi M-j resize-pane -D 1
bind -T copy-mode-vi M-k resize-pane -U 1
bind -T copy-mode-vi M-l resize-pane -R 1
# -----------------------------------------------------------------------------
# -- Plugins
# -----------------------------------------------------------------------------
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'aserowy/tmux.nvim'
set -g @plugin 'tmux-plugins/tmux-yank'
# Colorschemes
set -g @plugin 'wfxr/tmux-power'
set -g @tmux_power_theme 'moon'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'