You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/learn/getting-started/02_using_gitx/02_key_binds.md
+273Lines changed: 273 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,3 +5,276 @@ description: Setting custom keybinds in gitx
5
5
weight: 2
6
6
type: "docs"
7
7
---
8
+
9
+
## Overview
10
+
11
+
gitx is a keyboard-driven application with customizable keybindings. Every action in gitx can be remapped to your preferred key combination. This guide covers all available keybinds, how to customize them, and best practices for configuring your keyboard shortcuts.
12
+
13
+
## Configuration
14
+
15
+
Keybindings are configured in your gitx configuration file located at `~/.config/gitx/config.toml`. The keybindings section uses the following format:
-**Multiple key options**: `q,ctrl+c` (either key will trigger the action)
30
+
31
+
You can specify multiple alternative keybindings for a single action by separating them with commas.
32
+
33
+
## Default Keybindings
34
+
35
+
Here are all the default keybindings organized by category:
36
+
37
+
### Navigation
38
+
39
+
| Action | Default Key | Description |
40
+
|--------|-------------|-------------|
41
+
|`focus_next`|`tab`| Move to the next window |
42
+
|`focus_prev`|`shift+tab`| Move to the previous window |
43
+
|`focus_main`|`0`| Focus the commit graph (main window) |
44
+
|`focus_status`|`1`| Focus the status window |
45
+
|`focus_files`|`2`| Focus the files/changes window |
46
+
|`focus_branches`|`3`| Focus the branches window |
47
+
|`focus_commits`|`4`| Focus the commits window |
48
+
|`focus_stash`|`5`| Focus the stash window |
49
+
|`focus_command_log`|`6`| Focus the command log window |
50
+
|`up`|`k` or `↑`| Move up in lists |
51
+
|`down`|`j` or `↓`| Move down in lists |
52
+
53
+
### Files & Changes
54
+
55
+
| Action | Default Key | Description |
56
+
|--------|-------------|-------------|
57
+
|`stage_item`|`a`| Stage the selected file or change |
58
+
|`stage_all`|`space`| Stage all changes |
59
+
|`discard`|`d`| Discard changes in the selected file |
60
+
|`stash`|`s`| Stash the selected file |
61
+
|`stash_all`|`S`| Stash all changes |
62
+
|`commit`|`c`| Create a new commit |
63
+
64
+
### Branches
65
+
66
+
| Action | Default Key | Description |
67
+
|--------|-------------|-------------|
68
+
|`checkout`|`enter`| Checkout the selected branch |
69
+
|`new_branch`|`n`| Create a new branch |
70
+
|`delete_branch`|`d`| Delete the selected branch |
71
+
|`rename_branch`|`r`| Rename the selected branch |
72
+
73
+
### Commits
74
+
75
+
| Action | Default Key | Description |
76
+
|--------|-------------|-------------|
77
+
|`amend_commit`|`A`| Amend the last commit |
78
+
|`revert`|`v`| Revert the selected commit |
79
+
|`reset_to_commit`|`R`| Reset to the selected commit |
80
+
81
+
### Stash
82
+
83
+
| Action | Default Key | Description |
84
+
|--------|-------------|-------------|
85
+
|`stash_apply`|`a`| Apply a stash without removing it |
86
+
|`stash_pop`|`p`| Apply a stash and remove it |
87
+
|`stash_drop`|`d`| Delete the selected stash |
88
+
89
+
### Miscellaneous
90
+
91
+
| Action | Default Key | Description |
92
+
|--------|-------------|-------------|
93
+
|`switch_theme`|`ctrl+t`| Cycle through available themes |
94
+
|`toggle_help`|`?`| Show/hide the help panel |
95
+
|`escape`|`esc`| Cancel current action |
96
+
|`quit`|`q` or `ctrl+c`| Exit gitx |
97
+
98
+
## Customizing Keybindings
99
+
100
+
### Basic Customization
101
+
102
+
To customize a keybinding, add it to the `[keybindings]` section in your `~/.config/gitx/config.toml` file. For example:
103
+
104
+
```toml
105
+
[keybindings]
106
+
# Use 'l' instead of 'j' to move down
107
+
down = "l"
108
+
109
+
# Use 'h' instead of 'k' to move up
110
+
up = "h"
111
+
112
+
# Create a new branch with 'b'
113
+
new_branch = "b"
114
+
```
115
+
116
+
### Multiple Key Options
117
+
118
+
You can specify multiple keys that trigger the same action by separating them with commas:
119
+
120
+
```toml
121
+
[keybindings]
122
+
# Stage with either 'a' or 's'
123
+
stage_item = "a,s"
124
+
125
+
# Quit with 'q', ctrl+c, or ctrl+d
126
+
quit = "q,ctrl+c,ctrl+d"
127
+
128
+
# Switch themes with ctrl+t or ctrl+n
129
+
switch_theme = "ctrl+t,ctrl+n"
130
+
```
131
+
132
+
### Vim-like Configuration
133
+
134
+
Many users prefer vim-like keybindings. Here's a complete vim-inspired configuration:
135
+
136
+
```toml
137
+
[keybindings]
138
+
# Navigation
139
+
up = "k"
140
+
down = "j"
141
+
left = "h"
142
+
right = "l"
143
+
144
+
# File operations
145
+
stage_item = "a"
146
+
commit = "c"
147
+
discard = "d"
148
+
stash = "z"
149
+
150
+
# Branch operations
151
+
new_branch = "b"
152
+
checkout = "o"
153
+
delete_branch = "x"
154
+
rename_branch = "r"
155
+
156
+
# Commit operations
157
+
amend_commit = "e"
158
+
revert = "v"
159
+
reset_to_commit = "R"
160
+
161
+
# General
162
+
toggle_help = "?"
163
+
quit = "q"
164
+
escape = "esc"
165
+
```
166
+
167
+
### Emacs-like Configuration
168
+
169
+
For those preferring Emacs-style bindings:
170
+
171
+
```toml
172
+
[keybindings]
173
+
# Navigation (Ctrl+N/P for next/previous, Ctrl+F/B for forward/backward)
174
+
down = "ctrl+n"
175
+
up = "ctrl+p"
176
+
177
+
# Word navigation
178
+
focus_next = "ctrl+z"
179
+
focus_prev = "ctrl+shift+z"
180
+
181
+
# Common operations
182
+
stage_item = "ctrl+a"
183
+
discard = "ctrl+d"
184
+
stash = "ctrl+s"
185
+
commit = "ctrl+x"
186
+
187
+
# Help and exit
188
+
toggle_help = "ctrl+h"
189
+
quit = "ctrl+c"
190
+
escape = "esc"
191
+
```
192
+
193
+
### Arrow Key Configuration
194
+
195
+
If you prefer using arrow keys for navigation:
196
+
197
+
```toml
198
+
[keybindings]
199
+
# Use arrow keys
200
+
up = "up"
201
+
down = "down"
202
+
left = "left"
203
+
right = "right"
204
+
205
+
# Keep other keys for actions
206
+
stage_item = "a"
207
+
commit = "c"
208
+
new_branch = "n"
209
+
```
210
+
211
+
## Advanced Examples
212
+
213
+
### Minimal Keybinding Set
214
+
215
+
If you only want to change a few keybindings and keep most defaults:
216
+
217
+
```toml
218
+
[keybindings]
219
+
# Only customize your most-used actions
220
+
commit = "w"
221
+
stage_item = "s"
222
+
toggle_help = "h"
223
+
```
224
+
225
+
### Dvorak Layout Configuration
226
+
227
+
For Dvorak keyboard layout users:
228
+
229
+
```toml
230
+
[keybindings]
231
+
# Dvorak layout mappings (mapped to QWERTY position)
232
+
up = "o"
233
+
down = "a"
234
+
left = "s"
235
+
right = "e"
236
+
237
+
# Common operations using Dvorak
238
+
stage_item = "j"
239
+
commit = "b"
240
+
discard = "h"
241
+
new_branch = "c"
242
+
```
243
+
244
+
### Macros and Complex Workflows
245
+
246
+
While gitx doesn't support full macro systems, you can use common key combinations for your workflow:
247
+
248
+
```toml
249
+
[keybindings]
250
+
# Quick workflow keys
251
+
new_branch = "n"
252
+
stage_all = "s"
253
+
commit = "c"
254
+
checkout = "o"
255
+
delete_branch = "x"
256
+
257
+
# Focus shortcuts
258
+
focus_files = "2"
259
+
focus_branches = "3"
260
+
focus_commits = "4"
261
+
```
262
+
263
+
## Tips and Best Practices
264
+
265
+
1.**Avoid Conflicts**: Don't map the same key combination to multiple actions
266
+
2.**Use Modifiers Wisely**: Reserve Ctrl combinations for important actions you use frequently
267
+
3.**Consistency**: Try to keep your keybindings consistent with tools you already use (vim, tmux, etc.)
268
+
4.**Test Before Committing**: After changing a keybinding, test it in gitx to ensure it works
269
+
5.**Document Your Setup**: Keep notes on your custom keybindings for future reference
270
+
6.**Preserve Escape**: It's recommended to keep `escape` bound to `esc` as a safe abort key
271
+
272
+
## Viewing Active Keybindings
273
+
274
+
When inside gitx, press `?` (or your custom `toggle_help` key) to view the current active keybindings. This will show all keybindings for the currently focused panel.
275
+
276
+
## Configuration File Location
277
+
278
+
Your keybindings are stored in: `~/.config/gitx/config.toml`
279
+
280
+
If this file doesn't exist, gitx will create it with default settings the first time you run the application.
0 commit comments