tmux-btw

tmux-btw

https://git.tonybtw.com/tmux-btw.git git://git.tonybtw.com/tmux-btw.git
5,290 bytes raw
1
#+TITLE: Tmux Configuration
2
#+AUTHOR: Tony, btw
3
4
* Installation
5
6
This is my tmux config. It's a zero-plugin setup with vim-like keybindings and a Tokyo Night Moon theme.
7
8
To use this config, first make sure tmux is installed:
9
10
#+begin_src sh
11
# Arch
12
sudo pacman -S tmux
13
14
# Ubuntu/Debian
15
sudo apt install tmux
16
17
# macOS
18
brew install tmux
19
#+end_src
20
21
Then point tmux to this config by symlinking it:
22
23
#+begin_src sh
24
mkdir -p ~/.config/tmux
25
ln -sf /path/to/this/tmux.conf ~/.config/tmux/tmux.conf
26
#+end_src
27
28
Or if you just want to test it out without symlinking:
29
30
#+begin_src sh
31
tmux source-file /path/to/this/tmux.conf
32
#+end_src
33
34
* Configuration Breakdown
35
36
** Terminal and Display Settings
37
38
#+begin_src conf
39
set -g default-terminal "tmux-256color"
40
set -ga terminal-overrides ",*:RGB"
41
#+end_src
42
43
These lines enable 256-color support and true color (RGB) support. The first line tells tmux to advertise itself as a 256-color terminal, and the second enables 24-bit RGB colors. This is essential for proper color rendering in tools like Neovim.
44
45
#+begin_src conf
46
set -g mouse on
47
set -g set-clipboard on
48
#+end_src
49
50
Mouse support lets you click between panes and drag borders to resize. Clipboard integration means when you copy text in tmux, it goes to your system clipboard.
51
52
** Prefix Key
53
54
#+begin_src conf
55
unbind C-b
56
set -g prefix C-a
57
bind-key C-a send-prefix
58
#+end_src
59
60
This changes the prefix from =Ctrl-b= to =Ctrl-a= because it's way easier to reach. The third line lets you send the actual =Ctrl-a= to the terminal if needed.
61
62
** Pane Navigation
63
64
#+begin_src conf
65
bind h select-pane -L
66
bind j select-pane -D
67
bind k select-pane -U
68
bind l select-pane -R
69
#+end_src
70
71
Vim-style pane navigation. After hitting the prefix, you can use =h/j/k/l= to move between panes.
72
73
#+begin_src conf
74
bind -n M-h select-pane -L
75
bind -n M-j select-pane -D
76
bind -n M-k select-pane -U
77
bind -n M-l select-pane -R
78
#+end_src
79
80
The =-n= flag means "bind without prefix". So =Alt+h/j/k/l= lets you switch panes instantly without hitting prefix first.
81
82
** Splits
83
84
#+begin_src conf
85
unbind %
86
bind | split-window -h -c "#{pane_current_path}"
87
88
unbind '"'
89
bind - split-window -v -c "#{pane_current_path}"
90
#+end_src
91
92
Split windows with =prefix + |= for vertical and =prefix + -= for horizontal. The =-c "#{pane_current_path}"= part makes new panes open in the same directory as your current pane.
93
94
** Config Reload
95
96
#+begin_src conf
97
unbind r
98
bind r source-file $HOME/.config/tmux/tmux.conf
99
#+end_src
100
101
Reload your config with =prefix + r= without having to restart tmux.
102
103
** Window Management
104
105
#+begin_src conf
106
set -g base-index 1
107
set -g pane-base-index 1
108
set-window-option -g pane-base-index 1
109
set-option -g renumber-windows on
110
#+end_src
111
112
Start numbering windows and panes at 1 instead of 0. This is more ergonomic because window 1 is on the left of your keyboard. The =renumber-windows= option automatically renumbers windows when you close one, so you don't get gaps.
113
114
#+begin_src conf
115
bind -n M-1 select-window -t 1
116
bind -n M-2 select-window -t 2
117
# ... (continues through M-9)
118
#+end_src
119
120
Jump directly to windows with =Alt+1= through =Alt+9=, no prefix needed.
121
122
** Copy Mode
123
124
#+begin_src conf
125
set-window-option -g mode-keys vi
126
bind-key -T copy-mode-vi v send-keys -X begin-selection
127
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
128
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
129
unbind -T copy-mode-vi MouseDragEnd1Pane
130
#+end_src
131
132
Vim-style copy mode. Enter copy mode with =prefix + [=, navigate with =h/j/k/l=, press =v= to start selection, =y= to yank (copy). The =C-v= binding lets you do rectangle selection like in vim. The last line prevents mouse selection from exiting copy mode automatically.
133
134
** Theme
135
136
The rest of the config is the Tokyo Night Moon theme. The color variables are defined at the top:
137
138
#+begin_src conf
139
thm_bg="#222436"
140
thm_fg="#c8d3f5"
141
thm_cyan="#86e1fc"
142
# ... etc
143
#+end_src
144
145
The status bar shows:
146
- Current window with a checkmark and the last two parts of the current directory path
147
- Other windows showing just their index and name
148
- Right side shows window name, a visual indicator that changes color when prefix is pressed, and session name
149
150
The status bar format strings look complex but they're just using tmux's format variables like =#I= (window index), =#W= (window name), =#S= (session name), and conditional formatting with =#{?client_prefix,...}=.
151
152
* Keybindings Summary
153
154
| Bind               | Action                      |
155
|--------------------+-----------------------------|
156
| =Ctrl-a=           | Prefix key                  |
157
| =prefix + \vert=   | Split vertical              |
158
| =prefix + -=       | Split horizontal            |
159
| =prefix + h/j/k/l= | Navigate panes              |
160
| =Alt + h/j/k/l=    | Navigate panes (no prefix)  |
161
| =Alt + 1-9=        | Jump to window (no prefix)  |
162
| =prefix + r=       | Reload config               |
163
| =prefix + [=       | Enter copy mode             |
164
| =v= (copy mode)    | Start selection             |
165
| =y= (copy mode)    | Yank (copy) selection       |
166
167
* Notes
168
169
This config is heavily inspired by Henry Misc's zero-plugin approach. No TPM, no plugins, just native tmux features.
170
171
If you want to change the theme colors, just swap out the =thm_*= variables at the top with your preferred color scheme.