今天刚学到的(http://lixiaolai.com/alpha/notes/TextMate2.html#gem):
将以下脚本保存到/usr/local/bin
目录:
#!/bin/sh
usage()
{
echo "Usage: $(basename $0) <gem>" 1>&2
exit 1
}
GEM="$1"
[ -z "$GEM" ] && usage
mate "$(gem environment gemdir)/gems/$GEM"
并将其设置为“可执行脚本”:
chmod +x /usr/local/bin/mategem
在~/.bash_profile
文件中加入以下内容:
_mategem()
{
local curw
COMPREPLY=()
curw=${COMP_WORDS[COMP_CWORD]}
local gems="$(gem environment gemdir)/gems"
COMPREPLY=($(compgen -W '$(ls $gems)' -- $curw));
return 0
}
complete -F _mategem -o dirnames mategem
而后重新载入~/.bash_profile
:
source ~/.bash_profile
以后就可以输入“mategem bootstrap ⇥”而后得到mategem bootstrap-sass-2.1.1.0
……超级方便!
(learned from http://effectif.com/mac-os-x/textmate/opening-ruby-gems-in-textmate)