Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
zsh-syntax-highlighting paste performance improvement
Add the following in .zshrc:
...
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl)
...
### Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
}
pastefinish() {
zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish
### Fix slowness of pastes
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
...
@StrangeRanger
Copy link

I found that this worked as well: zstyle ':bracketed-paste-magic' active-widgets '.self-*'. I found the solution here: zsh-users/zsh-syntax-highlighting#295 (comment).
@magicdude4eva Do you know if there are any major differences between your solution and the one provided in the issue in the link I provided?

@magicdude4eva
Copy link
Author

magicdude4eva commented Mar 18, 2021

I do not think so - I just tried a number of things until performance was alright. I have honestly not looked at this since 2019. Surprised that this is seemingly not fixed and requires still a workaround.

@liranh85
Copy link

Worked perfectly for me - no more lags when pasting from the clipboard! 🎉

@Write
Copy link

Write commented Jun 14, 2021

As someone new to zsh && oh-my-zsh, thanks !

@spielhoelle
Copy link

Thanks worked

@GussSoares
Copy link

It's amazing! thank you so much for this, to paste now is so fast!

@GussSoares
Copy link

It's amazing! thank you so much for this, to paste now is so fast!

@shubhammatta
Copy link

Thanks! it worked.

@avatar-lavventura
Copy link

Are we required to source zsh-syntax-highlighting ?

@kohane27
Copy link

Are we required to source zsh-syntax-highlighting ?

I've disabled sourcing zsh-syntax-highlighting.zsh and the fix still works.

@ksingh7
Copy link

ksingh7 commented Feb 3, 2022

Thanks, worked like charm @magicdude4eva when I visit your neighborhood, beer is on Me. Cheers

@brianbc2021
Copy link

Thanks! works for me :)

@yinlongsea
Copy link

it works for me, thanks

@ToontjeM
Copy link

ToontjeM commented Dec 5, 2022

Please submit to the zsh-syntax-highlighting maintainer as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment