diff options
author | Koichi Murase <myoga.murase@gmail.com> | 2024-01-29 19:35:34 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-29 10:35:34 +0000 |
commit | 2ef516935747eaacacbe9e075fbc5a23ea9c2a15 (patch) | |
tree | 335ac79bca4a29c5a9d023766b5a2eebd3e8bff6 | |
parent | bdcb143996567c9540fb411bc53448355665747b (diff) |
feat(zsh): update widget names (#1631)
The current widget names for Zsh start with "_", which gives an
impression to users that those widgets are internal API and should not
be bound by the users. However, we actually instruct users to set up
custom keybindings by specifying them to bindkey.
In other shells, a separate namespace for widgets are not prepared, so
we want to prefix "_" to shell function names to tell the users that
these are not the commands that are supposed to be called from the
command line. However, the widget names are separated in their own
namespace in Zsh, so we do not have to isolate them by prefixing "_".
In fact, other frameworks such as `fzf` define widgets with names not
starting with "_".
In this patch, we update the widget names to have the form "atuin-*".
The old widget names that existed in the release version <= 17.2.1 are
left for compatibility.
-rw-r--r-- | atuin/src/command/init.rs | 22 | ||||
-rw-r--r-- | atuin/src/shell/atuin.zsh | 12 | ||||
-rw-r--r-- | docs/ru/key-binding_ru.md | 8 | ||||
-rw-r--r-- | docs/zh-CN/key-binding.md | 8 |
4 files changed, 27 insertions, 23 deletions
diff --git a/atuin/src/command/init.rs b/atuin/src/command/init.rs index 2d4b0e51e..eb841c9f5 100644 --- a/atuin/src/command/init.rs +++ b/atuin/src/command/init.rs @@ -32,17 +32,17 @@ impl Cmd { println!("{base}"); if std::env::var("ATUIN_NOBIND").is_err() { - const BIND_CTRL_R: &str = r"bindkey -M emacs '^r' _atuin_search_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 -bindkey -M viins '^[[A' _atuin_up_search_viins_widget -bindkey -M emacs '^[OA' _atuin_up_search_widget -bindkey -M vicmd '^[OA' _atuin_up_search_vicmd_widget -bindkey -M viins '^[OA' _atuin_up_search_viins_widget -bindkey -M vicmd 'k' _atuin_up_search_vicmd_widget"; + const BIND_CTRL_R: &str = r"bindkey -M emacs '^r' atuin-search +bindkey -M viins '^r' atuin-search-viins +bindkey -M vicmd '/' atuin-search"; + + const BIND_UP_ARROW: &str = r"bindkey -M emacs '^[[A' atuin-up-search +bindkey -M vicmd '^[[A' atuin-up-search-vicmd +bindkey -M viins '^[[A' atuin-up-search-viins +bindkey -M emacs '^[OA' atuin-up-search +bindkey -M vicmd '^[OA' atuin-up-search-vicmd +bindkey -M viins '^[OA' atuin-up-search-viins +bindkey -M vicmd 'k' atuin-up-search-vicmd"; if !self.disable_ctrl_r { println!("{BIND_CTRL_R}"); diff --git a/atuin/src/shell/atuin.zsh b/atuin/src/shell/atuin.zsh index 152d674f2..8cfba3b4d 100644 --- a/atuin/src/shell/atuin.zsh +++ b/atuin/src/shell/atuin.zsh @@ -96,9 +96,13 @@ _atuin_up_search_viins() { add-zsh-hook preexec _atuin_preexec add-zsh-hook precmd _atuin_precmd +zle -N atuin-search _atuin_search +zle -N atuin-search-vicmd _atuin_search_vicmd +zle -N atuin-search-viins _atuin_search_viins +zle -N atuin-up-search _atuin_up_search +zle -N atuin-up-search-vicmd _atuin_up_search_vicmd +zle -N atuin-up-search-viins _atuin_up_search_viins + +# These are compatibility widget names for "atuin <= 17.2.1" users. zle -N _atuin_search_widget _atuin_search -zle -N _atuin_search_vicmd_widget _atuin_search_vicmd -zle -N _atuin_search_viins_widget _atuin_search_viins zle -N _atuin_up_search_widget _atuin_up_search -zle -N _atuin_up_search_vicmd_widget _atuin_up_search_vicmd -zle -N _atuin_up_search_viins_widget _atuin_up_search_viins diff --git a/docs/ru/key-binding_ru.md b/docs/ru/key-binding_ru.md index 487d34b98..d6917e4e3 100644 --- a/docs/ru/key-binding_ru.md +++ b/docs/ru/key-binding_ru.md @@ -15,17 +15,17 @@ eval "$(atuin init zsh)" # zsh -Autin устанавливает виджет ZLE "\_atuin_search_widget" +Autin устанавливает виджет ZLE "atuin-search" ``` export ATUIN_NOBIND="true" eval "$(atuin init zsh)" -bindkey '^r' _atuin_search_widget +bindkey '^r' atuin-search # зависит от режима терминала -bindkey '^[[A' _atuin_search_widget -bindkey '^[OA' _atuin_search_widget +bindkey '^[[A' atuin-search +bindkey '^[OA' atuin-search ``` # bash diff --git a/docs/zh-CN/key-binding.md b/docs/zh-CN/key-binding.md index 3e7f2f958..54c68b372 100644 --- a/docs/zh-CN/key-binding.md +++ b/docs/zh-CN/key-binding.md @@ -13,17 +13,17 @@ eval "$(atuin init zsh)" # zsh -Atuin 定义了 ZLE 部件 "\_atuin_search_widget" +Atuin 定义了 ZLE 部件 "atuin-search" ``` export ATUIN_NOBIND="true" eval "$(atuin init zsh)" -bindkey '^r' _atuin_search_widget +bindkey '^r' atuin-search # 取决于终端模式 -bindkey '^[[A' _atuin_search_widget -bindkey '^[OA' _atuin_search_widget +bindkey '^[[A' atuin-search +bindkey '^[OA' atuin-search ``` # bash |