Commit 36fea45b authored by Andrew Janke's avatar Andrew Janke
Browse files

svn plugin: urldecode repo info

The repo location reported by `svn` is a URL. If you don't decode it before using it a prompt, the `%` sequences will be misinterpreted by prompt expansion and give screwy results.
Fixes #2233
parent 00eb4658
# vim:ft=zsh ts=2 sw=2 sts=2 # vim:ft=zsh ts=2 sw=2 sts=2
# #
function svn_prompt_info() { function svn_prompt_info() {
local _DISPLAY
if in_svn; then if in_svn; then
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
unset SVN_SHOW_BRANCH unset SVN_SHOW_BRANCH
_DISPLAY=$(svn_get_branch_name) _DISPLAY=$(svn_get_branch_name)
else else
_DISPLAY=$(svn_get_repo_name) _DISPLAY=$(svn_get_repo_name)
_DISPLAY=$(omz_urldecode "${_DISPLAY}")
fi fi
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR" $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR"
unset _DISPLAY
fi fi
} }
...@@ -30,7 +31,7 @@ function svn_get_repo_name() { ...@@ -30,7 +31,7 @@ function svn_get_repo_name() {
} }
function svn_get_branch_name() { function svn_get_branch_name() {
_DISPLAY=$( local _DISPLAY=$(
svn info 2> /dev/null | \ svn info 2> /dev/null | \
awk -F/ \ awk -F/ \
'/^URL:/ { \ '/^URL:/ { \
...@@ -49,7 +50,6 @@ function svn_get_branch_name() { ...@@ -49,7 +50,6 @@ function svn_get_branch_name() {
else else
echo $_DISPLAY echo $_DISPLAY
fi fi
unset _DISPLAY
} }
function svn_get_rev_nr() { function svn_get_rev_nr() {
...@@ -60,7 +60,7 @@ function svn_get_rev_nr() { ...@@ -60,7 +60,7 @@ function svn_get_rev_nr() {
function svn_dirty_choose() { function svn_dirty_choose() {
if in_svn; then if in_svn; then
root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
...@@ -77,7 +77,7 @@ function svn_dirty() { ...@@ -77,7 +77,7 @@ function svn_dirty() {
function svn_dirty_choose_pwd () { function svn_dirty_choose_pwd () {
if in_svn; then if in_svn; then
root=$PWD local root=$PWD
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment