Comments (2)
I tried modifying this file. comment some code snippets.
but ctrl + r,
still brings up the history widget.
#!/bin/zsh
zmodload zsh/complist
zmodload -F zsh/parameter p:funcstack p:functions
zmodload -F zsh/terminfo p:terminfo
local -Pa prefix=( '\e'{\[,O} )
typeset -ga _autocomplete__key_up=( ${^prefix}A )
typeset -ga _autocomplete__key_down=( ${^prefix}B )
typeset -ga _autocomplete__key_alt_up=( '\e'$^_autocomplete__key_up '\e[1;3A' )
typeset -ga _autocomplete__key_alt_down=( '\e'$^_autocomplete__key_down '\e[1;3B' )
${0}:bind() {
local -P keymap=$1 widget=$2
shift 2
builtin bindkey -M "$keymap" "${@:^^widget}"
}
${0}:bind-menu() {
0=${0%:*}
${0}:bind isearch "$@"
${0}:bind menuselect "$@"
}
${0}:bound() {
[[ $( builtin bindkey -M "$1" "$3" ) == \"[^[:space:]]##\"\ $2 ]]
}
${0}:rebind() {
0=${0%:*}
local -P keymap=$1 old=$2 new=$3 key=
shift 3
for key; do
${0}:bound "$keymap" "$old" "$key" &&
builtin bindkey -M "$keymap" "$key" "$new"
done
}
${0}:unbind() {
0=${0%:*}
${0}:bound "$1" "$2" "$3" &&
builtin bindkey -M "$1" -r "$2"
}
${0}:bind main up-line-or-search $_autocomplete__key_up[@]
${0}:bind-menu up-history $_autocomplete__key_up[@]
${0}:bind main down-line-or-select $_autocomplete__key_down[@]
${0}:bind-menu down-history $_autocomplete__key_down[@]
${0}:rebind emacs up-line-or-{history,search} '^P'
${0}:bind-menu up-history '^P'
${0}:rebind emacs down-line-or-{history,select} '^N'
${0}:bind-menu down-history '^N'
${0}:rebind vicmd up-line-or-{history,search} 'k'
${0}:rebind vicmd down-line-or-{history,select} 'j'
local -Pa menukeys=(
'^@' accept-and-hold
'^_' .undo
"$terminfo[kpp]" backward-word
"$terminfo[knp]" forward-word
'^[v' backward-word
'^V' forward-word
)
builtin bindkey -M isearch "$menukeys[@]"
builtin bindkey -M menuselect "$menukeys[@]"
${0}:precmd() {
emulate -L zsh
setopt $_autocomplete__func_opts[@]
0=${0%:*}
${0}:rebind main expand-or-complete complete-word '\t'
${0}:rebind main expand-or-complete-prefix complete-word '\t'
${0}:rebind main menu-expand-or-complete complete-word '\t'
local backtab=$terminfo[kcbt]
${0}:rebind main undefined-key insert-unambiguous-or-complete "$backtab"
${0}:bound main complete-word '\t' &&
${0}:bind-menu accept-line '\t'
${0}:bind main history-search-backward $_autocomplete__key_alt_up[@]
${0}:bind-menu vi-backward-blank-word $_autocomplete__key_alt_up[@]
${0}:bind main menu-select $_autocomplete__key_alt_down[@]
${0}:bind-menu vi-forward-blank-word $_autocomplete__key_alt_down[@]
# ${0}:rebind emacs history-search-backward history-search-backward '\ep'
# ${0}:bind-menu vi-backward-blank-word '\ep'
# ${0}:rebind emacs history-search-forward menu-select '\en'
# ${0}:bind-menu vi-forward-blank-word '\en'
# ${0}:rebind vicmd vi-rev-repeat-search history-search-backward 'N'
# ${0}:rebind vicmd vi-repeat-search menu-select 'n'
# ${0}:rebind emacs history-incremental-search-backward{,} '^R'
# ${0}:bind-menu history-incremental-search-backward '^R'
# ${0}:rebind emacs history-incremental-search-forward menu-search '^S'
# ${0}:bind-menu history-incremental-search-forward '^S'
# ${0}:rebind vicmd {vi-history,history-incremental}-search-backward '/'
# ${0}:rebind vicmd vi-history-search-forward menu-search '?'
unset -m '_autocomplete__key_*'
unfunction ${0}:{{,re,un}bind,bound}
}
from zsh-autocomplete.
it took me almost two days to find out that there is apparently no way to rebind builtin shortcuts because of that shitty precmd trick to bind the keys just before the prompt appears. Works only if I manually execute bindkey in prompt.
What I tried:
source $XDG_DATA_HOME/zinit/plugins/marlonrichert---zsh-autocomplete/zsh-autocomplete.plugin.zsh
testfunc() {
echo "test"
zle reset-prompt
}
zle -N testfunc
bindkey '\E[1;3A' testfunc # Alt-Up
Zsh log:
+/home/emon/.config/zsh/.zshrc:169> bindkey '\E[1;3A' testfunc
+.autocomplete__key-bindings:precmd:16> .autocomplete__key-bindings:bind main history-search-backward '\e\e[A' '\e\eOA' '\e[1;3A'
+.autocomplete__key-bindings:bind:3> bindkey -M main '\e\e[A' history-search-backward '\e\eOA' history-search-backward '\e[1;3A' history-search-backward
IMHO that should be added to README to not to misguide the other people
from zsh-autocomplete.
Related Issues (20)
- Conflict between zoxide, zsh-autocomplete, and fzf results in erroneous behavior HOT 1
- Bug with zsh-syntax-highlighting: unhandled ZLE widget HOT 5
- Available completions not shown for commands with slow `compdef` functions
- Enable suggestion scrolling without setting a hard limit HOT 1
- Autocomplete do not work on my zsh terminal HOT 1
- Up and Down arrow keys are not working to navigate across completions.
- Hangs when offline HOT 3
- Esc to exit menus HOT 1
- History menu rendering broken by powerlevel10k kubecontext plugin. HOT 1
- Autocompletion Not Working HOT 5
- ZSH segfault when zsh-autosuggestions is enabled HOT 1
- Crashes zsh when typing HOT 6
- Recent paths is not show after changing using keybinds HOT 2
- Show menu selection options by number
- Freezes for a few seconds on entering a command HOT 2
- zsh-autocomplete prevents zoxide's popup from exiting HOT 1
- Unnecessary tilde expansions supersede directory and file completions HOT 4
- Change group order or disable some groups completely in dropdown HOT 1
- Error: autocomplete:_expand:old:17: command not found: _autocomplete__is_glob HOT 1
- Should it be loaded after zsh-completions?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zsh-autocomplete.