svn diff 和 vimdiff 切换脚本

1 新建修改subversion配置的脚本:/usr/local/bin/svndiff.sh
#!/bin/bash

diff="diff"
if [ $1 = $diff ]
then
    echo "$1"; 
    if [ -z $2 ]   #字符串长度不为0
    then
        echo "svn diff"
        sed -i 's/.*diff-cmd=\/usr\/local\/bin\/diffwrap\.sh/#diff-cmd=\/usr\/local\/bin\/diffwrap\.sh/g' ~/.subversion/config  
        svn diff
    else
        echo "svn diff {$2}"
        sed -i 's/.*#diff-cmd=\/usr\/local\/bin\/diffwrap/diff-cmd=\/usr\/local\/bin\/diffwrap/g' ~/.subversion/config  
        svn $*
    fi
else
    echo "$*"
    svn $* 
fi
sed -i 's/.*diff-cmd=\/usr\/local\/bin\/diffwrap\.sh/#diff-cmd=\/usr\/local\/bin\/diffwrap\.sh/g' ~/.subversion/config  
echo "zkdiff finish!"
2.修改配置/etc/profile,在文件最后添加
    alias zksvn='/usr/local/bin/svndiff.sh '
3.在终端运行 source /etc/profile让配置生效
以后只要运行 zksvn diff xxx.c就能使用vimdiff对比文件

你可能感兴趣的:(脚本)