Closed artfulrobot closed 3 years ago
That's probably caused by 46509997646fbaa8d37c8494cc56014bf5ee2d7f.
Does the problem go away when paste this into your command line?
add-zle-hook-widget -d line-init .autocomplete.key.normal-mode
app-mode() {
echoti smkx
return 0
}
add-zle-hook-widget line-init app-mode
How have you defined your key bindings? Can you paste the relevant part of your dotfiles here?
@marlonrichert hi. Yes.
Without that code, pressing ↑ presents a menu of recent history that I can scroll through with ↑↓ or ←→ or Tab (the only way to exit the menu seems to be Enter or Space).
With that code, pressing ↑ puts the latest history item on the command line; no history list is shown, instead I get the list of completions that I would see had I typed the currently-shown command line; pressing ↑ again goes to the previous history and ↓ later. The ←→ keys work as normal (i.e. they move left and right one character in the command line).
Here's what I think are the relevant parts of my .zshrc file
### start antigen
source ~/bin/conf/antigen.zsh;
# Syntax highlighting bundle.
antigen bundle zsh-users/zsh-syntax-highlighting
# Autocomplete
# Without the next one you get errors about zpty unknown command.
antigen bundle mafredri/zsh-async
#antigen bundle marlonrichert/zsh-autocomplete@dev
antigen bundle marlonrichert/zsh-autocomplete@main
antigen bundle marlonrichert/zsh-edit@main
# This one did not work:
# antigen bundle zsh-autocomplete
# Tell Antigen that you're done.
antigen apply
### end antigen
HISTFILE=~/.histfile
HISTSIZE=2000
SAVEHIST=2000
# Prevent saving 'rm' commands to history.
zshaddhistory() {
case ${1%% *} in
(rm) return 1;;
# can do like (rm|xx|yy) return 1;;
esac
return 0;
}
setopt inc_append_history extendedglob nomatch notify
unsetopt beep
# cdr for recend dirs. Documentation is at
# http://zsh.sourceforge.net/Doc/Release/User-Contributions.html
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
# NOT Vim mode keybindings
# bindkey -v
bindkey -e
# reduces timeout for switching modes to 0.1s
export KEYTIMEOUT=1
# sets up colour arrays in fg[] bg[]...
autoload colors; colors
# or use print -P '%F{red}...%f'
# add to fpath, the paths that are searched for autocomplete functions.
# todo: this looks wrong, we regex against a string but then add to it as an array?
for p in "$HOME/bin/conf/zsh-completion-functions" "$HOME/.bin/conf/zsh-completion-functions"
do
if [[ -d "$p" && ! "$fpath" =~ "(^| )$p( |$)" ]] ; then
fpath=($p $fpath)
fi
done
# use pushd so you can see recent dirs with `dirs -v` and go to a numbered entry like `~2` (and cdr?)
setopt autocd autopushd
# without the following, typing watch then SPACE changes 'watch' to 'batch'!
zstyle ':autocomplete:*' magic off
zstyle ':autocomplete:tab:*' widget-style menu-select
zstyle ':autocomplete:*' min-input 2
#
# http://zshwiki.org/home/zle/bindkeys
#
# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
# up-line-or-history
# history-beginning-search-backward
# down-line-or-history
# history-beginning-search-forward
# setup key accordingly
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" history-beginning-search-backward
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" history-beginning-search-forward
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if [[ -n ${terminfo[smkx]} ]] && [[ -n ${terminfo[rmkx]} ]]; then
function zle-line-init () {
echoti smkx
}
function zle-line-finish () {
echoti rmkx
}
zle -N zle-line-init
zle -N zle-line-finish
fi
# Control + left/right
bindkey "[1;5C" emacs-forward-word
bindkey "[1;5D" emacs-backward-word
# ... while inside tmux (why is this different?)
bindkey "[C" emacs-forward-word
bindkey "[D" emacs-backward-word
# reverse search
# bindkey "^R" history-incremental-pattern-search-backward
# Can override this in .zshrc.conf
# default host colour yellow
: ${PS1_HOST_COLOUR:=yellow}
#SOLAR_GREY=4 - comes out blue?
# emit title character codes.
printf "\e]2;$(hostname -s)\a"
arprompt_lastdir=
arprompt_lastgit=
arprompt_lastcmd=
tmux_version=$(tmux -V|cut -c6-)
#
# If we have tmux, update the bottom info row.
#
updateTmuxFooter() {
[[ -z "$TMUX" ]] && return
info="${arprompt_lastgit} ${arprompt_keychain}"
if [[ $tmux_version[0,1] -eq 2 && ${${a#2.}%[a-z]*} -lt 7 ]]
then
# old tmux
printf '\033]2;%s\033\' "${info}"
else
# new tmux
tmux select-pane -T "${info}"
fi
}
# Allow comments on the command line (well, der, yes please)
setopt interactivecomments
# Use Drush's autocomplete built for bash.
if [[ -e "$HOME/.composer/vendor/drush/drush/drush.complete.sh" ]]
then
autoload bashcompinit
bashcompinit
source ~/.composer/vendor/drush/drush/drush.complete.sh
fi
storeLastCommand() {
arprompt_lastcmd="$3"
}
add-zsh-hook preexec storeLastCommand
# compdef _gd gd
Thanks, that clears it up for me. I know how to fix that.
# without the following, typing watch then SPACE changes 'watch' to 'batch'! zstyle ':autocomplete:*' magic off
You can remove those lines, by the way. This has not been true for quite a while now. 🙂
# ... while inside tmux (why is this different?)
Because tmux
has its own key codes. It's a virtual terminal emulator inside your virtual terminal. As such, it also changes the $TERM
variable, causing $terminfo
to output different codes. 🙂
All right, it should be fixed now.
@marlonrichert Awesome, it is fixed!
Also, thanks for your comments about my comments - I hadn't left them in there as questions for you; they're just notes for myself about why I did things! Great to have your input though!
zsh-autocomplete
version: 1658d38581c57764dd25980c8a36ff095cf686bbSince upgrading to ↑ today my left and right keys don't work as they did:
i.e. they used to work and now they jump by words. This also seems to disrupt the menu selection, e.g. history selection.
I tried reproducing with the above steps but I can't, but the change has only come in since upgrading zsh-autocomplete.
As an aside, in your super helpful instructions for the bug template, how about this to make it easier to copy-n-paste to get the plugin path: