1 Star 1 Fork 3

_KK/useful-scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cp-svn-url.sh 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
oldratlee 提交于 2018-06-24 23:18 . emojify
#!/bin/bash
# @Function
# copy the svn remote url of current svn directory.
#
# @Usage
# $ ./cp-svn-url.sh
# $ ./cp-svn-url.sh /path/to/svn/work/dir
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/vcs.md#-cp-svn-urlsh
# @author ivanzhangwb (ivanzhangwb at gmail dot com)
readonly PROG=`basename $0`
usage() {
cat <<EOF
Usage: ${PROG} [DIR]
Copy the svn remote url of local svn directory
DIR is local svn directory, default is current directory.
Example:
${PROG}
${PROG} /path/to/svn/work/dir
Options:
-h, --help display this help and exit
EOF
exit $1
}
for a; do
[ -h = "$a" -o --help = "$1" ] && usage
done
[ $# -gt 1 ] && { echo At most 1 local directory is need! ; usage 1; }
readonly dir="${1:-.}"
readonly url="$(svn info "${dir}" | awk '/^URL: /{print $2}')"
if [ -z "${url}" ]; then
echo "Fail to get svn url!" 1>&2
exit 1
fi
copy() {
case "`uname`" in
Darwin*)
pbcopy ;;
CYGWIN*|MINGW*)
clip ;;
*)
xsel -b ;;
esac
}
echo -n "${url}" | copy && echo "${url} copied!"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/luokai/useful-scripts.git
git@gitee.com:luokai/useful-scripts.git
luokai
useful-scripts
useful-scripts
master

搜索帮助