Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save magicdude4eva/2d4748f8ef3e6bf7b1591964c201c1ab to your computer and use it in GitHub Desktop.
Save magicdude4eva/2d4748f8ef3e6bf7b1591964c201c1ab to your computer and use it in GitHub Desktop.
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
...
@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