-
Notifications
You must be signed in to change notification settings - Fork 7
/
tmux.conf
114 lines (94 loc) · 4.56 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
set-option -sa terminal-overrides ",xterm-ghostty:RGB"
# set -g default-terminal "tmux-256color"
set -g default-terminal "screen-256color"
# tell Tmux that outside terminal supports true color
set -ga terminal-overrides ",xterm-256color*:Tc"
# Undercurl, taken from: https://github.com/folke/lsp-colors.nvim
set -g default-terminal "${TERM}"
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' # undercurl support
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' # underscore colours - needs tmux-3.0
# Fix copy and paste: `brew install reattach-to-user-namespace`
if-shell 'test "$(uname -s)" = Darwin' 'set-option -g default-command "exec reattach-to-user-namespace -l zsh"'
# start window numbers at 1 to match keyboard order with tmux window order
set -g base-index 1
# start pane indexing at 1 for tmuxinator
set-window-option -g pane-base-index 1
# renumber windows sequentially after closing any of them
set -g renumber-windows on
# Faster escape sequences (default is 500ms).
# This helps when exiting insert mode in Vim: http://superuser.com/a/252717/65504
set -s escape-time 50
# Bigger scrollback buffer
set -g history-limit 10000
# Neovim says it needs this
set-option -g focus-events on
# 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 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-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 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
# Resize the panes with prefix+arrow keys
bind Up resize-pane -U 5
bind Down resize-pane -D 5
bind Left resize-pane -L 5
bind Right resize-pane -R 5
# Rebind 'clear screen' to <prefix>+c-l
bind C-l send-keys 'C-l'
# Rebind spit and new-window commands to use current path
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Bind C-s to fuzzy switch session
bind -n C-s \
split-window -l 10 'session=$(tmux list-sessions -F "#{session_name}" | fzf --query="$1" --select-1 --exit-0) && tmux switch-client -t "$session"' \;
# Style status bar
set -g status-style fg=white,bg=black
set -g window-status-current-style fg=green,bg=black
set -g pane-active-border-style fg=green,bg=black
set -g window-status-format " #I:#W#F "
set -g window-status-current-format " #I:#W#F "
set -g window-status-current-style bg=green,fg=black
set -g window-status-activity-style bg=black,fg=yellow
set -g window-status-separator ""
set -g status-justify centre
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi v send -X begin-selection
# Setup 'y' to copy selection as in Vim
# Use reattach-to-user-namespace with pbcopy on OS X
# Use xclip on Linux
set -g set-clipboard off
if-shell 'test "$(uname -s)" = Darwin' 'bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy 2> /dev/null"' 'bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "xclip -i -selection clipboard"'
# Fix for ssh-agent (http://fredkelly.net/articles/2014/10/19/developing_on_yosemite.html)
set -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_C"
# Mousemode
# Toggle mouse on with ^B m
bind m \
set -g mouse on \;\
display 'Mouse Mode: ON'
# Toggle mouse off with ^B M
bind M \
set -g mouse off \;\
display 'Mouse Mode: OFF'
# Move current window to the left with Ctrl-Shift-Left
bind-key -n C-S-Left swap-window -t -1
# Move current window to the right with Ctrl-Shift-Right
bind-key -n C-S-Right swap-window -t +1
# Open a "test" split-window at the bottom
bind t split-window -f -l 15 -c "#{pane_current_path}"
# Open a "test" split-window at the right
bind T split-window -h -f -p 35 -c "#{pane_current_path}"