The SVN plugin of the oh-my-zsh ZSH distribution is not working with the agnoster theme, because it's simple not used in the prompt of the theme.
Here two adaption of the theme file (themes/agnoster.zsh-theme
) are listed, which are showing a nice prompt when you are in a SVN working directory.
- Using the SVN plugin (with dirty symbol)
prompt_svn() {
local rev branch
if in_svn; then
rev=$(svn_get_rev_nr)
branch=$(svn_get_branch_name)
prompt_segment yellow black
echo -n "$rev@$branch"
if [ `svn_dirty_choose_pwd 1 0` -eq 1 ]; then
prompt_segment red black
echo -n "±"
fi
fi
}
- Not using the SVN plugin (faster, without dirty symbol, maybe not working in all circumstances)
upsearch () {
slashes=${PWD//[^\/]/}
directory="$PWD"
for (( n=${#slashes}; n>0; --n ))
do
test -e "$directory/$1" && return 0
directory="$directory/.."
done
return 1
}
prompt_svn() {
local svn_info rev branch
#if [ -d ".svn" ]; then
upsearch .svn
if [ $? -eq 0 ]; then
svn_info="$(svn info 2> /dev/null)";
if [ $? -eq 0 ]; then
rev=$(echo $svn_info | sed -n 's/Revision:\ //p')
branch=$(echo $svn_info | \
awk -F/ \
'/^URL:/ { \
for (i=0; i<=NF; i++) { \
if ($i == "branches" || $i == "tags" ) { \
print $(i+1); \
break;\
}; \
if ($i == "trunk") { print $i; break; } \
} \
}'
)
prompt_segment yellow black
echo -n "$rev@$branch"
fi
fi
}
For that adoption I reused code of the SVN plugin, as well as code of an answer at unix.stackexchange.com.
To get it work you have to include one of the above code snippets into your agnoster theme file (themes/agnoster.zsh-theme
) and adapt the build_prompt
function to include the call of the prompt_svn
function. Like:
build_prompt() {
RETVAL=$?
prompt_status
prompt_virtualenv
prompt_context
prompt_dir
prompt_git
prompt_hg
prompt_svn
prompt_end
}