Skip to content

Commit 90c9451

Browse files
committed
docs(configuration): describe new utility "atuin-bind" for Bash
1 parent 7188ffe commit 90c9451

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

src/content/docs/configuration/key-binding.mdx

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,55 @@ used in combination with the config
9090

9191
## bash
9292

93-
Atuin provides a bindable shell function "`__atuin_history`" for keybindings in
94-
Bash. The flag `--shell-up-key-binding` can be optionally specified to the
95-
first argument for keybindings to the <kbd>up</kbd> key or similar keys.
93+
Atuin (`>= 18.10.0`) provides a shell function `atuin-bind` to set up
94+
keybindings easily:
95+
96+
```
97+
atuin-bind [-m KEYMAP] KEYSEQ COMMAND
98+
```
99+
100+
`KEYMAP` is one of `emacs`, `vi-insert`, and `vi-command` and specifies the
101+
target keymap where the keybinding is defined. `KEYSEQ` specifies a key
102+
sequence in the format used in `bind '"KEYSEQ": ...'`. `COMMAND` specifies a
103+
shell command to run with the keybindings. The following special commands can
104+
be used as well as an arbitrary shell command:
105+
106+
| Command | Description |
107+
| ----------------------- | ----------------------------------------------------------------------------------- |
108+
| `atuin-search` | Standard search |
109+
| `atuin-search-emacs` | Standard search with the `emacs` keymap mode |
110+
| `atuin-search-viins` | Standard search with the `vim-insert` keymap mode |
111+
| `atuin-search-vicmd` | Standard search with the `vim-insert` keymap mode |
112+
| `atuin-up-search` | Search command for <kbd>up</kbd> or similar keys |
113+
| `atuin-up-search-emacs` | Search command for <kbd>up</kbd> or similar keys, with the `emacs` keymap mode |
114+
| `atuin-up-search-viins` | Search command for <kbd>up</kbd> or similar keys, with the `vim-insert` keymap mode |
115+
| `atuin-up-search-vicmd` | Search command for <kbd>up</kbd> or similar keys, with the `vim-insert` keymap mode |
116+
117+
The keymap mode controls the initial keymap in the Atuin search and is
118+
determined in combination with the config
119+
["keymap\_mode"](https://docs.atuin.sh/configuration/config/#keymap_mode)
120+
(`atuin >= 18.0`).
121+
96122

97123
```
98124
export ATUIN_NOBIND="true"
99125
eval "$(atuin init bash)"
100126
101127
# bind to ctrl-r, add any other bindings you want here too
102-
bind -x '"\C-r": __atuin_history'
128+
atuin-bind '\C-r' atuin-search
103129
104130
# bind to the up key, which depends on terminal mode
105-
bind -x '"\e[A": __atuin_history --shell-up-key-binding'
106-
bind -x '"\eOA": __atuin_history --shell-up-key-binding'
131+
atuin-bind '\e[A' atuin-up-search
132+
atuin-bind '\eOA' atuin-up-search
107133
```
108134

109-
For the keybindings in the `vi` editing mode, the options
110-
`--keymap-mode=vim-insert` and `--keymap-mode=vim-normal` (`atuin >= 18.0`) can
111-
be additionally specified to the shell function `__atuin_history` in
112-
combination with the config
113-
["keymap\_mode"](https://docs.atuin.sh/configuration/config/#keymap_mode)
114-
(`atuin >= 18.0`) to start the Atuin search in respective keymap modes.
135+
With older versions of Atuin, the user needs to bind a bindable shell function
136+
"`__atuin_history`" directly using Bash's `bind`. The flag
137+
`--shell-up-key-binding` can be optionally specified to the first argument for
138+
keybindings to the <kbd>up</kbd> key or similar keys. For the keybindings in
139+
the `vi` editing mode, the options `--keymap-mode=vim-insert` and the keymap
140+
mode `--keymap-mode=vim-normal` (`atuin >= 18.0`) can be additionally specified
141+
to the shell function `__atuin_history`.
115142

116143
## fish
117144
Edit key bindings in FISH shell by adding the following to ~/.config/fish/config.fish

src/content/docs/guide/installation.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ After installing, remember to restart your shell.
163163
While Atuin will ignore commands prefixed with whitespace, they may still end up in your bash history.
164164
Please check your configuration! All other shells do not have this issue.
165165

166-
To use Atuin in `bash < 4` with bash-preexec, the option `enter_accept` needs
167-
to be turned on (which is so by default).
166+
To use `atuin < 18.10.0` in `bash < 4` with bash-preexec, the option
167+
`enter_accept` needs to be turned on (which is so by default). There is no
168+
restriction in the latest version of Atuin (>= 18.10.0).
168169

169170
bash-preexec cannot properly invoke the `preexec` hook for subshell commands
170171
`(...)`, function definitions `func() { ...; }`, empty for-in-statements `for

0 commit comments

Comments
 (0)