How to disable zsh substitution/autocomplete with URL and backslashes

后端 未结 4 427
不知归路
不知归路 2020-12-08 22:50

I am using zsh with oh-my-zsh on Ubuntu:14.04.

The shell autocompletes escape character with backslash when I paste a URL.

For ex

4条回答
  •  自闭症患者
    2020-12-08 23:24

    update 2019-05-12:

    new version(> 486fa10) oh-my-zsh have a configuration for this, add DISABLE_MAGIC_FUNCTIONS=true before source $ZSH/oh-my-zsh.sh:

    DISABLE_MAGIC_FUNCTIONS=true
    source $ZSH/oh-my-zsh.sh
    

    via: https://github.com/robbyrussell/oh-my-zsh/commit/486fa1010df847bfd8823b4492623afc7c935709


    Original answer:

    This is a bug in zsh 5.1.1 ~ 5.2(current).

    The plugin bracketed-paste-magic did not works in the zsh versions.

    The issue is here:

    • https://github.com/zsh-users/zsh-autosuggestions/issues/102
    • https://github.com/robbyrussell/oh-my-zsh/issues/5499
    • https://github.com/robbyrussell/oh-my-zsh/commit/35517457921c095be1aa6ed948debfbe183b89ac

    I suggest you disable bracketed-paste-magic.

    Comment these code from oh-my-zsh's ~/.oh-my-zsh/lib/misc.zsh solve the problem:

    if [[ $ZSH_VERSION != 5.1.1 ]]; then
      for d in $fpath; do
        if [[ -e "$d/url-quote-magic" ]]; then
          if is-at-least 5.1; then
            autoload -Uz bracketed-paste-magic
            zle -N bracketed-paste bracketed-paste-magic
          fi
          autoload -Uz url-quote-magic
          zle -N self-insert url-quote-magic
          break
        fi
      done
    fi
    

    via

提交回复
热议问题