mirror of
https://github.com/atuinsh/atuin.git
synced 2025-02-16 10:30:44 +01:00
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.
This commit is contained in:
parent
bdcb143996
commit
2ef5169357
@ -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_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_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_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}");
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user