ZSH 不断在我粘贴的 URL 中添加反斜杠

Lew*_*uce 12 zsh

我已经尝试过如何使用 URL 和反斜杠禁用 zsh 替换/自动完成中的解决方案,但这不再起作用。

如果我粘贴 URL,它会不断添加反斜杠。很烦人。

例如:

https://www.google.com?test=sample1&test2=sample3
Run Code Online (Sandbox Code Playgroud)

会变成:

curl -X POST "https://www.google.com\?test\=sample1\&test2\=sample3"
Run Code Online (Sandbox Code Playgroud)

这是我的文件的顶部~/.zshrc

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
DISABLE_MAGIC_FUNCTIONS=true
export ZSH=/Users/myuser/.oh-my-zsh
Run Code Online (Sandbox Code Playgroud)

我已经尝试重新调用源代码,但没有成功。我能够解决这个问题的唯一方法是打开一个 bash shell,这可能非常不方便。

小智 6

搜索后这对我有用

  1. 打开文件~/.oh-my-zsh/lib/misc.zsh
  2. 评论下面这些行
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
Run Code Online (Sandbox Code Playgroud)

最终结果是

autoload -Uz is-at-least

# *-magic is known buggy in some versions; disable if so
# if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; 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

## jobs
setopt long_list_jobs

env_default 'PAGER' 'less'
env_default 'LESS' '-R'

## super user alias
alias _='sudo '

## more intelligent acking for ubuntu users
if (( $+commands[ack-grep] )); then
  alias afind='ack-grep -il'
else
  alias afind='ack -il'
fi

# recognize comments
setopt interactivecomments
Run Code Online (Sandbox Code Playgroud)

相关链接

https://github.com/ohmyzsh/ohmyzsh/issues/5499

如何使用 URL 和反斜杠禁用 zsh 替换/自动完成