From 7ebb5e9ddaedf15bd261772119268076f8965489 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Mon, 6 Nov 2017 11:58:05 -0800 Subject: [PATCH] environment: Fix logic around url quoting in zsh >= 5.1 Closes #1015, Fixes #978 Thanks to @Eriner for pointing us in right direction. The code for this comes from zim. This is the last commit with the code we're using: https://github.com/Eriner/zim/commit/537f07660376f6fd0b8103ee993bfc132ddcee90#diff-30465d78a41f73dc0f6967d3f34d7964 Note that we need this workaround because we currently support back to 4.3.11. I believe that originally came from here: https://github.com/robbyrussell/oh-my-zsh/pull/4473 --- modules/environment/init.zsh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/environment/init.zsh b/modules/environment/init.zsh index 76655a6c..e77a107c 100644 --- a/modules/environment/init.zsh +++ b/modules/environment/init.zsh @@ -9,8 +9,24 @@ # Smart URLs # -autoload -Uz url-quote-magic -zle -N self-insert url-quote-magic +# This logic comes from an old version of zim. Essentially, bracketed-paste was +# added as a requirement of url-quote-magic in 5.1, but in 5.1.1 bracketed +# paste had a regression. Additionally, 5.2 added bracketed-paste-url-magic +# which is generally better than url-quote-magic so we load that when possible. +autoload -Uz is-at-least +if [[ ${ZSH_VERSION} != 5.1.1 ]]; then + if is-at-least 5.2; then + autoload -Uz bracketed-paste-url-magic + zle -N bracketed-paste bracketed-paste-url-magic + else + if is-at-least 5.1; then + autoload -Uz bracketed-paste-magic + zle -N bracketed-paste bracketed-paste-magic + fi + fi + autoload -Uz url-quote-magic + zle -N self-insert url-quote-magic +fi # # General