用ctags为linux系统头文件生成systags

来源:互联网 发布:新还珠格格第三部知画 编辑:程序博客网 时间:2024/05/16 12:54
#!/bin/bash# Program:#   This program is used to generate system ctags for vim editor and auto add path for vim#History:# 2012/12/6     Kom     First releasePATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/~/binexport PATH# The ctags result will be store at /home/$(USER)/.vim/systagssystagsdirpath="/home/${USER}/.vim/"systagspath="${systagsdirpath}systags"#echo ${systagsdirpath}#echo ${systagspath}# detect specific directory is exist# return:#   0: exist#   1: doesn't exist#   2: parameters number errorfunction isdirexist(){    if [ $# -eq 0 ] || [ $# -gt 1 ]; then        return 2    fi    if [ -d $1 ]; then        return 0    else        return 1    fi}#detect specific file is exist#return:#   0: exist#   1: doesn't exist#   2: parameters number errorfunction isfileexist(){    if [ $# -eq 0 ] || [ $# -gt 1 ]; then        return 2    fi    if [ -e $1 ]; then        return 0    else        return 1    fi}# if the dir to store systags doesn't exist, create itisdirexist ${systagsdirpath}if [ $? == 1 ]; then    echo -n "'"${systagsdirpath}"' doesn't exist, now create ... "    mkdir ${systagsdirpath}    isdirexist ${systagsdirpath}    if [ $? == 0 ]; then        echo "success."    else        echo "FAILED."        return 1    fielse    echo "'"${systagsdirpath}"' already exist."fi# if the systags file already exist, delete itisfileexist ${systagspath}if [ $? == 1 ]; then    echo "'"${systagspath}"' doesn't exist."else    echo -n "'"${systagspath}"' already exist, now delete is ... "    rm -fr ${systagspath}    isfileexist ${systagspath}    if [ $? == 1 ]; then        echo "success."    else        echo "FAILED."        return 1    fifi# now, generate tags fileecho -n "Now, generate system ctags for vim editor ... "ctags -I __THROW -I __attribute__ -I __attribute_pure__ -I __nonnull --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --c++-kinds=+p --fields=+iaS --extra=+q -R -f ${systagspath} /usr/include /usr/local/include#ctags -I __THROW -I __attribute__ -I __attribute_pure__ -I __nonnull --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --c++-kinds=+p --fields=+iaS --extra=+q -f ${systagspath} /usr/include/* /usr/include/sys/* /usr/include/bits/* /usr/include/netinet/* /usr/include/arpa/* /usr/include/mysql/*echo "success."# now, add it to the vimecho -n "Now, add it to the vim ... "echo "set tags+=${systagspath}" >> /home/${USER}/.vimrcecho "success."

0 0
原创粉丝点击