如何使用 URL 和反斜杠禁用 zsh 替换/自动完成 [英] How to disable zsh substitution/autocomplete with URL and backslashes

查看:65
本文介绍了如何使用 URL 和反斜杠禁用 zsh 替换/自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu:14.04 上使用 zshoh-my-zsh.

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

当我粘贴 URL 时,shell 会自动完成带有反斜杠的转义字符.

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

以环境变量为例:

$ wget http://{DEFAULT_IP}/index.html
It will become:
$ wget http://\{DEFAULT_IP\}/index.html

如何禁用此功能?

推荐答案

2019-05-12更新:

update 2019-05-12:

new version(> 486fa10) oh-my-zsh 对此有一个配置,在 source $ZSH/oh-my-zsh.sh 之前添加 DISABLE_MAGIC_FUNCTIONS=true:

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

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

原答案:

这是 zsh 5.1.1 ~ 5.2(当前)中的一个错误.

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

插件 bracketed-paste-magic 在 zsh 版本中不起作用.

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

问题在这里:

我建议你禁用bracketed-paste-magic.

在oh-my-zsh的~/.oh-my-zsh/lib/misc.zsh中评论这些代码解决问题:

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

通过

这篇关于如何使用 URL 和反斜杠禁用 zsh 替换/自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆