I've just got into zsh recently, mainly to use it for git on vscode only (cause it looked superr goood)
I've been using fish for a very long time, and even now I'm using it as my default shell
So I'm trying to configure zsh to behave more like fish as I'm more comfortable with how the latter works, I've got plugins like zsh-autosuggestions to allow command previews (man it only remembers commands, doesn't detect folders :c) and powerlevel10k for the clean look on git
When it comes to keybinding, I'm used to having tab key works as autocomplete the previewed command on fish, which i indeed found a solution | bindkey '\t' autosuggest-accept |, i added it to ~/.zshrc and it worked like a charm. However, I'm stuck on having my right arrow key to work like forward one character on the preview instead of completing the whole command in zsh.
For instance, neofetch in the terminal, after i typed neo
it will have grayed out text 'fetch' at the end of the command neo'fetch' (ignore the quotes, think of it as grayed)
when i press tab, it will auto-complete the command for me neofetch
what i wanted for my right arrow key instead, is to only auto-complete one character for me, which would be neof'etch'
then right arrow key again, neofe'tch'
again, neofet'ch'
and again and again until it completes the command
i can simply achieve this in fish by doing | bind \e[C forward-single-char |
I've looked through | bindkey -M main | but i couldn't find any similar solution in zsh
Is it possible to have this on zsh? This is my first question on stack overflow, sorry if its too long >.<
What has worked for me is based on an answer on Reddit. https://www.reddit.com/r/zsh/comments/hextyh/zshautosuggestions_use_arrow_left_for_partial/
Add the following lines at the very end of "~/.zshrc":
# Remove "forward-char" widgets from "ACCEPT".
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=("${(@)ZSH_AUTOSUGGEST_ACCEPT_WIDGETS:#forward-char}")
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=("${(@)ZSH_AUTOSUGGEST_ACCEPT_WIDGETS:#vi-forward-char}")
# Add "forward-char" widgets to "PARTIAL_ACCEPT".
ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS+=(forward-char)
ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS+=(vi-forward-char)
# Add a custom widget to complete partially.
autosuggest_partial_charwise() {
zle forward-char
}
zle -N autosuggest_partial_charwise
bindkey "${terminfo[kcuf1]}" autosuggest_partial_charwise
# Add "autosuggest_partial_charwise" to "IGNORE".
ZSH_AUTOSUGGEST_IGNORE_WIDGETS+=(autosuggest_partial_charwise)