编辑tired.cpp文件很累有没有?有了vix后就很简单了。
使用前:
vim a/b/c/d/e/f/tired.cpp
vix使用后,在源码的任意目录下执行下面的命令,就能打开tired.cpp:
vix tired.cpp
这么神器?怎么搞?!很简单!
- 将以下代码加入到~/.bashrc:
export VIX_HOME='/home/raywill/dev/'
function vix { [ $(find $VIX_HOME -name $1 -type f | wc -l) == 1 ] && /usr/bin/vim $(find $VIX_HOME-name $1 -type f | head -1) $2 || find $VIX_HOME -name $1 -type f; }
_vix()
{
local list;
local cur prev exe;
exe=${COMP_WORDS[0]};
cur=${COMP_WORDS[COMP_CWORD]};
prev=${COMP_WORDS[COMP_CWORD - 1]};
list=$(find $VIX_HOME -type f \( -name "*.cpp" -or -name "*.h" \) -name "$cur*" -exec basename {} \;);
COMPREPLY=($(compgen -W "$list" -- ${cur}))
return 0;
}
complete -F _vix vix
- source ~/.bashrc
以上神器,来自@符风 http://sydi.org