May 3, 2010

关于SVN的外部diff工具

公司的项目用的SVN, 也还好, 虽然慢点. 但是它的diff和merge实在是human-unreadable.

还好, SVN可以使用外部的diff工具, 例如vimdiff, 只要写个下面那样的脚本, 然后将svn的config中diff-cmd指向它就好.

另外关于diff3, 我的理解刚开始和svn的merge不同, svn实际上是将两个版本的差异变化实施到当前版本. 我想用vimdiff来实现, 最后cat合并后的本地版本以满足svn的要求, 但是一直有问题, 还差点在生产中出状况, 而且这个用的也不多, 所以暂时放下. 有那位大侠实现了vimdiff作为svn的diff3-cmd, 请一定告诉我, 联系方式见About.

#!/bin/sh

# Configure your favorite diff program here.
DIFF="vimdiff"

if [ -z $2 ]
then
	echo ERROR: This script expects to be called by subversion
	exit 1
fi

# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT=${6}
RIGHT=${7}

# Call the diff command (change the following line to make sense for
# your merge program).
#$DIFF --left $LEFT --right $RIGHT
$DIFF $LEFT $RIGHT

# Return an errorcode of 0 if no differences were detected, 1 if some were.
# Any other errorcode will be treated as fatal.
exit 0

May 3, 2010

我的配置文件和脚本

放在了Github上. 真的是超喜欢Git, 又快又方便, 和Vim整合的又好.

最近有时间会详细解释下各个配置文件, 例如bash, screen, vim, mutt等, 敬请期待.

网页浏览:

http://github.com/adam8157/

Git clone:

git clone git://github.com/adam8157/dotfiles.git
git clone git://github.com/adam8157/scripts.git

May 2, 2010

Vim配合xsel访问剪贴板

话说我一直在虚拟终端下用vim的, 但是有个问题, 普通版本的vim无法访问中键和系统剪贴板, 这也不是大问题, 鼠标选就是了, 但是有时候需要和虚拟机交互, 要知道我这连leafpad都没装, 所有的编辑工作全是vim, 为了这么点事把vim的图形库装上实在是让我不爽.

好在, 有xsel, 用它配合vim就能访问中键和系统剪贴板, 洁癖狂和折腾狂再一次胜利了.

代码放在后面, 可以看到, 我把它们伪装成了*和+寄存器, 但是功能和原版的有差别, 只能先yank在再复制到剪贴板, paste没问题. 至于为什么不用xclip, xclip会因为detach在关闭vim后失效, xsel却能避免, 虽然会产生一个错误log, 但是把这个log指向/dev/null就好.

PS: 哪位大仙如果知道如何简单将区块传给命令而不是叹号filter这种形式, 一定告诉我.

" Use xsel to access the x clipboard
if $DISPLAY != '' && executable('xsel')
	nnoremap <silent> "*y :'[,']!xsel -i -p -l /dev/null<CR>u
	nnoremap <silent> "*p :r!xsel -p<CR>
	nnoremap <silent> "+y :'[,']!xsel -i -b -l /dev/null<CR>u
	nnoremap <silent> "+p :r!xsel -b<CR>
endif

——–Better Way——–

" Use xsel to access the X clipboard
if $DISPLAY != '' && executable('xsel')
	nnoremap <silent> "*y :'[,']w !xsel -i -p -l /dev/null<CR>
	nnoremap <silent> "*p :r!xsel -p<CR>
	nnoremap <silent> "+y :'[,']w !xsel -i -b -l /dev/null<CR>
	nnoremap <silent> "+p :r!xsel -b<CR>
endif

May 2, 2010

Genesis - Let there be a blog

开博的想法由来已久.

为什么开? 这是个好问题.

1, 大家都有, 作为一个不甘人后的无畏青年, 我, 必须有一个.

2, 自己需要一个记录计算机学习, 工作琐事, 感情生活的自留地.

Adam Lee said, Let there be a blog: and there was a blog.