Skip to content

Commit

Permalink
feat(shell)!: bind the Atuin search to "/" in vi-normal mode (#1629)
Browse files Browse the repository at this point in the history
A search feature in the vi-normal mode of shells can be called by "/".
To make the shell-integration keybindings consistent with the existing
shell keybindings, we add the keybinding to "/" in this patch.

This patch removes the Ctrl-r binding in the "vicmd" keymap in Zsh.
The key Ctrl-r is used for the `redo` operation in the vi-normal mode
by default.  We would like to avoid overwriting an existing keybinding
with a totally different feature.
  • Loading branch information
akinomyoga committed Jan 26, 2024
1 parent 230bf2d commit 2e48e21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions atuin/src/command/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ impl Cmd {

if std::env::var("ATUIN_NOBIND").is_err() {
const BIND_CTRL_R: &str = r"bindkey -M emacs '^r' _atuin_search_widget
bindkey -M vicmd '^r' _atuin_search_vicmd_widget
bindkey -M viins '^r' _atuin_search_viins_widget";
bindkey -M viins '^r' _atuin_search_viins_widget
bindkey -M vicmd '/' _atuin_search_widget";

const BIND_UP_ARROW: &str = r"bindkey -M emacs '^[[A' _atuin_up_search_widget
bindkey -M vicmd '^[[A' _atuin_up_search_vicmd_widget
Expand Down
1 change: 1 addition & 0 deletions atuin/src/shell/atuin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ if [[ $__atuin_bind_ctrl_r == true ]]; then
# the vi_nmap keymap in ble.sh.
bind -m emacs -x '"\C-r": __atuin_history --keymap-mode=emacs'
bind -m vi-insert -x '"\C-r": __atuin_history --keymap-mode=vim-insert'
bind -m vi-command -x '"/": __atuin_history --keymap-mode=emacs'
fi

# shellcheck disable=SC2154
Expand Down

0 comments on commit 2e48e21

Please sign in to comment.