Closed RegreTTO closed 1 year ago
My best guess would be autocomplete is sourced after z-sy-h, so z-sy-h can't wrap that key bind. Please double check the order plugins are sourced.
I've put this plugin on the top of the others, but it hasn't helped
This is a part from my .zshrc
# ZSH Highlighting settings
typeset -A ZSH_HIGHLIGHT_STYLES
ZSH_HIGHLIGHT_STYLES[default]='fg=cyan'
ZSH_HIGHLIGHT_STYLES[path]='underline, standout'
ZSH_HIGHLIGHT_STYLES[builtin]='fg=#65c7c4, bold'
ZSH_HIGHLIGHT_STYLES[command]='fg=#65c7c4, bold'
ZSH_HIGHLIGHT_STYLES[alias]='fg=#65c7c4, bold'
ZSH_THEME="bira"
plugins=(
zsh-syntax-highlighting
git
gitignore
zsh-autosuggestions
virtualenv
copyfile
interactive-cd
z
)
z-sy-h should be last not first. See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md#oh-my-zsh
Unfortunatelly after moving it down nothing's changed
I think this can't be caused by using z-sy-h on top of zsh -f
, so we'll have to close this as unreproducible unless someone comes up with a reproduction recipe.
I have a similar issue, when typing sud
, the zsh-autosuggestions
plugin suggests my last command which is sudo dnf install difftastic
:
When pressing the right arrow to autocomplete it, completes it properly but the syntax highlighting is incorrect:
Meanwhile while typing it manually in its entirety does show it properly:
Pressing the right arrow shows where you pressed it if you do it midway through:
My dotfiles are here: https://github.com/AndreasBackx/dotfiles. In my latest commit as of writing I move the plugin to the end, but that does not seem to make a difference. If I can help make a reproducible sample, I would love to try but don't know how right now. I have this problem on at least 2 machines, perhaps 3. Definitely 1 Fedora 37 and 1 Arch Linux machine, possibly 1 other Fedora 37 machine that I cannot test right now.
uname -a
: Linux andreasbackx-fedora-S4PE2053 6.1.7-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jan 18 17:11:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
zsh --version
: zsh 5.9 (x86_64-redhat-linux-gnu)oh-my-zsh
and all plugins are the latest version as of writing.Let me know if there's something else I can provide.
If I can help make a reproducible sample, I would love to try but don't know how right now.
In short: run zsh -f
and therein: use the source
builtin to load the relevant plugins (as few as possible, of course); run echo
or true
or :
with some arguments to populate history; type another command (and possibly press [Tab] or [→] or whatever) to reproduce the problem. Also, include the commit hashes of everything, don't just say "latest". Thanks :)
Same problem after upgrading from Ubuntu 22.04 to 22.10.
As @danielshahaf suggested, I tried to sequentially source plugins in no-rcs mode and check at every step if the problem appears:
zhenya% source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
zhenya% source ~/.zsh/colorize/colorize.plugin.zsh
zhenya% source ~/.zsh/zsh-command-not-found/command-not-found.plugin.zsh
zhenya% source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
At this point everything works as it worked before (I suppose, the right color for suggestions is grabbed from my terminal colors).
So, I tried another line from my .zshrc
:
zhenya% ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#7F7864'
After that, accepted suggestions began to be highlighted incorrectly.
Removing this line from .zshrc
solved the problem for me. But, interestingly, setting another color also corrects highlighting:
zhenya% ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#777777'
Additionally, I noticed that everything works fine with hex colors without letters. Hope, this will be useful for somebody.
In short: run
zsh -f
and therein: use thesource
builtin to load the relevant plugins (as few as possible, of course); runecho
ortrue
or:
with some arguments to populate history; type another command (and possibly press [Tab] or [→] or whatever) to reproduce the problem. Also, include the commit hashes of everything, don't just say "latest". Thanks :)
@danielshahaf
So running zsh -f
I can reproduce it as follows:
$ plugins=(zsh-autosuggestions zsh-syntax-highlighting)
$ source $HOME/.oh-my-zsh/oh-my-zsh.sh
$ echo 1
Then typing echo
and right arrow will lead to the bug.
Without oh-my-zsh and sourcing the files directly also leads to the problem so it seems to be unrelated to oh-my-zsh?
What @gashnya says I can reproduce as well.
Thus if I set it to my default, it fixed it for me.
Just after writing this previous comment I noticed that I have the following in my dotfiles:
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=0"
Turns out that was the problem for me. Just removing that fixes the problem.
It turns out that setting that explicitly makes for the bug...
It does so for explicit colour numbers:
And for hex codes:
Fixed it in my dotfiles here: https://github.com/AndreasBackx/dotfiles/commit/4c14884a9f5b5d4297f52bfe898f7a7ce77b0c97
Thanks for the additional information.
I'd like to repeat that I requested minimal reproduction recipes, involving as few external dependencies as possible. That means one external plugin is better than three, and without omz is better than with.
Anyway, I can reproduce this now using
To reproduce:
$ zsh-5.9 -f
% bindkey -e
% . ./asug
% . ./zsyh
% ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#FF00FF'
% echo true
true
% echo «press Ctrl+E»
true
Note that this only reproduces with uppercase hex digits (!). With lowercase hex digits it's fine.
"Reproduces" means that the stuff added by the press of Ctrl+E is in #FF00FF rather than in whatever colour z-sy-h would have it.
Duplicate of https://github.com/zsh-users/zsh-autosuggestions/issues/698; see Oliver's comments there for the recommended solution (tl;dr z-asug should use the memo=
feature of zsh≥5.9).
To be clear, this isn't a bug in z-sy-h.
When I type some path beginning it is highlighted by red as it should be, but after I use autocomplete, typed part is still red while the rest part of the path is highlighted normally
In this example I've typed
~/.oh-my-zsh/
manually and then invoked autocomplete