ZSH keeps putting backslashes in my pasted URLS

Viewed 851

I have already tried the solution at How to disable zsh substitution/autocomplete with URL and backslashes, but this is no longer working.

If I paste a URL, it keeps putting backslashes. Very annoying.

For example:

https://www.google.com?test=sample1&test2=sample3

will become:

curl -X POST "https://www.google.com\?test\=sample1\&test2\=sample3"

Here's the top of my ~/.zshrc file:

# 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

I have already tried to re-call the source, no luck. The only way I've been able to get around this is to open up a bash shell instead, which can be extremely inconvenient.

1 Answers

After search this worked for me

  1. open the file ~/.oh-my-zsh/lib/misc.zsh
  2. comment these lines below
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

the final result is

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

Relative Links

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

How to disable zsh substitution/autocomplete with URL and backslashes

Related