Skip to content

Clear auto suggestions when bracketed paste is run #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions etc/zsh/zshrc.dist
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,22 @@ setopt promptsubst
setopt printexitvalue

# https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/safe-paste/safe-paste.plugin.zsh
# https://github.com/zsh-users/zsh-autosuggestions/issues/511#issuecomment-962671126
set zle_bracketed_paste # Explicitly restore this zsh default
autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic
autoload -U url-quote-magic bracketed-paste-magic
zle -N self-insert url-quote-magic

pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to check that this line is safe? It's rather complex and not quoted.

zle -N self-insert 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

## base for any shell
source ${zsh_custom_dir}/shrc
Expand All @@ -61,6 +74,8 @@ if test "$color_prompt" = "yes"; then
## Enable auto-suggestions based on the history
if test -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh; then
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=30
typeset -a ZSH_AUTOSUGGEST_CLEAR_WIDGETS
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(bracketed-paste)
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
fi
## Highlight commands as you type
Expand Down Expand Up @@ -90,6 +105,3 @@ fi
if test -f /etc/zsh_command_not_found; then
source /etc/zsh_command_not_found
fi