终端粘贴字符自动加入反斜杠问题

问题描述

当我向 macOS 终端粘贴字符时,终端会自动为其添加反斜杠。

比如说我原始的内容是这样:

wget http://{DEFAULT_IP}/index.htmlIt will become:

粘贴之后,就会变成这样:

wget http://\{DEFAULT_IP\}/index.html

解决方法

造成上述问题的原因是你使用了 Oh My Zsh 插件,而 Oh My Zsh 插件中有一个名为 Magic Functions 的功能,该功能会自动在你粘贴内容时加入转义字符。

要关闭该功能,打开 ~/.zshrc 文件,找到这一行:

# DISABLE_MAGIC_FUNCTIONS="true"

将其取消注释。

最后你的 ~/.zshrc 文件的内容应该是这样:

# zstyle ':omz:update' frequency 13

# Uncomment the following line if pasting URLs and other text is messed up.
DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

参考:Disable url escaping in quotes strings #7632 | GitHub

posted @ 2024-03-12 12:43  Undefined443  阅读(49)  评论(0编辑  收藏  举报