如何使用 URL 和反斜杠禁用 zsh 替换/自动完成 [英] How to disable zsh substitution/autocomplete with URL and backslashes
问题描述
我在 Ubuntu:14.04 上使用 zsh
和 oh-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.
问题在这里:
- https://github.com/zsh-users/zsh-autosuggestions/问题/102
- https://github.com/robbyrussell/oh-my-zsh/问题/5499
- https://github.com/robbyrussell/oh-my-zsh/提交/35517457921c095be1aa6ed948debfbe183b89ac
我建议你禁用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屋!