#!/bin/sh
# filename:
# createproject.sh
#echo $HOME
if [ "$1" = "help" ] ; then
echo "Usage:"
echo " createproject.sh [projectname]"
exit 0
fi
if [ "$1" = "" ] ; then
echo "please input your project-name"
exit 1
fi
PROJECT=$1
CSCOPE_DIR=$HOME/.vim/prj_cscope
TAGS_DIR=$HOME/.vim/prj_tags
PLUGIN_DIR=$HOME/.vim/plugin
mkdir -p $CSCOPE_DIR
mkdir -p $TAGS_DIR
mkdir -p $PLUGIN_DIR
find $PWD -name "*.h" -o -name "*.c" -o -name "*.cc" > $CSCOPE_DIR/cscope.files
cscope -bkq -i $CSCOPE_DIR/cscope.files -f $CSCOPE_DIR/cscope_$PROJECT.out
#echo $PWD
ctags -f $TAGS_DIR/tag_$PROJECT -R $PWD --c++-kinds=+p --fields=+iaS --extra=+q
echo "set tags+=$TAGS_DIR/tag_$PROJECT" > $PLUGIN_DIR/prj_$PROJECT.vim
echo "if has(\"cscope\")" >> $PLUGIN_DIR/prj_$PROJECT.vim
echo "set csprg=/usr/bin/cscope" >> $PLUGIN_DIR/prj_$PROJECT.vim
echo "set csto=1" >> $PLUGIN_DIR/prj_$PROJECT.vim
echo "set cst" >> $PLUGIN_DIR/prj_$PROJECT.vim
echo "set nocsverb" >> $PLUGIN_DIR/prj_$PROJECT.vim
echo "if filereadable(\"$CSCOPE_DIR/cscope_$PROJECT.out\")" >> $PLUGIN_DIR/prj_$PROJECT.vim
echo "cs add $CSCOPE_DIR/cscope_$PROJECT.out" >> $PLUGIN_DIR/prj_$PROJECT.vim
echo "endif" >> $PLUGIN_DIR/prj_$PROJECT.vim
echo "set csverb" >> $PLUGIN_DIR/prj_$PROJECT.vim
echo "endif" >> $PLUGIN_DIR/prj_$PROJECT.vim
#############################################################################################
删除ctags, cscope.out的脚本:
#!/bin/sh
# filename:
# deleteproject.sh
#echo $HOME
if [ "$1" = "help" ] ; then
echo "Usage:"
echo " deleteproject.sh [projectname]|[]"
exit 0
fi
PROJECT=$1
CSCOPE_DIR=$HOME/.vim/prj_cscope
TAGS_DIR=$HOME/.vim/prj_tags
PLUGIN_DIR=$HOME/.vim/plugin
if [ "$PROJECT" = "" ] ; then
rm -f $CSCOPE_DIR/*
rm -f $TAGS_DIR/*
rm -f $PLUGIN_DIR/prj_*.vim
else
rm -f $CSCOPE_DIR/cscope_$PROJECT.out*
rm -f $TAGS_DIR/tag_$PROJECT
rm -f $PLUGIN_DIR/prj_$PROJECT.vim
fi
阅读(757) | 评论(0) | 转发(0) |