Add ATUIN_NOBIND (#62)
* Add ATUIN_NOBIND * Update docs/key-binding.md `<kbd>`, what magic Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com> Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>
This commit is contained in:
parent
035bf9a99b
commit
8bd4d12cfa
4 changed files with 43 additions and 3 deletions
|
@ -57,6 +57,7 @@ I wanted to. And I **really** don't want to.
|
||||||
- [Cloud history sync](docs/sync.md)
|
- [Cloud history sync](docs/sync.md)
|
||||||
- [History stats](docs/stats.md)
|
- [History stats](docs/stats.md)
|
||||||
- [Running your own server](docs/server.md)
|
- [Running your own server](docs/server.md)
|
||||||
|
- [Key binding](docs/key-binding.md)
|
||||||
|
|
||||||
## Supported Shells
|
## Supported Shells
|
||||||
|
|
||||||
|
|
38
docs/key-binding.md
Normal file
38
docs/key-binding.md
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# Key binding
|
||||||
|
|
||||||
|
By default, Atuin will rebind both <kbd>Ctrl-r</kbd> and the up arrow. If you do not want
|
||||||
|
this to happen, set ATUIN_NOBIND before the call to `atuin init`
|
||||||
|
|
||||||
|
For example
|
||||||
|
|
||||||
|
```
|
||||||
|
export ATUIN_NOBIND="true"
|
||||||
|
eval "$(atuin init zsh)"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then choose to bind Atuin if needed, do this after the call to init.
|
||||||
|
|
||||||
|
# zsh
|
||||||
|
|
||||||
|
Atuin defines the ZLE widget "\_atuin_search_widget"
|
||||||
|
|
||||||
|
```
|
||||||
|
export ATUIN_NOBIND="true"
|
||||||
|
eval "$(atuin init zsh)"
|
||||||
|
|
||||||
|
bindkey '^r' _atuin_search_widget
|
||||||
|
|
||||||
|
# depends on terminal mode
|
||||||
|
bindkey '^[[A' _atuin_search_widget
|
||||||
|
bindkey '^[OA' _atuin_search_widget
|
||||||
|
```
|
||||||
|
|
||||||
|
# bash
|
||||||
|
|
||||||
|
```
|
||||||
|
export ATUIN_NOBIND="true"
|
||||||
|
eval "$(atuin init bash)"
|
||||||
|
|
||||||
|
# bind to ctrl-r, add any other bindings you want here too
|
||||||
|
bind -x '"\C-r": __atuin_history'
|
||||||
|
```
|
|
@ -27,4 +27,6 @@ __atuin_history ()
|
||||||
preexec_functions+=(_atuin_preexec)
|
preexec_functions+=(_atuin_preexec)
|
||||||
precmd_functions+=(_atuin_precmd)
|
precmd_functions+=(_atuin_precmd)
|
||||||
|
|
||||||
|
if [[ -z $ATUIN_NOBIND ]]; then
|
||||||
bind -x '"\C-r": __atuin_history'
|
bind -x '"\C-r": __atuin_history'
|
||||||
|
fi
|
||||||
|
|
|
@ -3,7 +3,6 @@ autoload -U add-zsh-hook
|
||||||
|
|
||||||
export ATUIN_SESSION=$(atuin uuid)
|
export ATUIN_SESSION=$(atuin uuid)
|
||||||
export ATUIN_HISTORY="atuin history list"
|
export ATUIN_HISTORY="atuin history list"
|
||||||
export ATUIN_BINDKEYS="true"
|
|
||||||
|
|
||||||
_atuin_preexec(){
|
_atuin_preexec(){
|
||||||
id=$(atuin history start "$1")
|
id=$(atuin history start "$1")
|
||||||
|
@ -42,7 +41,7 @@ add-zsh-hook precmd _atuin_precmd
|
||||||
|
|
||||||
zle -N _atuin_search_widget _atuin_search
|
zle -N _atuin_search_widget _atuin_search
|
||||||
|
|
||||||
if [[ $ATUIN_BINDKEYS == "true" ]]; then
|
if [[ -z $ATUIN_NOBIND ]]; then
|
||||||
bindkey '^r' _atuin_search_widget
|
bindkey '^r' _atuin_search_widget
|
||||||
|
|
||||||
# depends on terminal mode
|
# depends on terminal mode
|
||||||
|
|
Loading…
Reference in a new issue