现在的位置: 首页 > 综合 > 正文

cscope中这样生成cscope.files

2013年10月13日 ⁄ 综合 ⁄ 共 485字 ⁄ 字号 评论关闭

find `pwd` -name "*.[ch]" -o -name "*.cpp" > cscope.files
cscope -bR -i cscope.files

上述命令中使用`pwd`取得绝对路径名,以防止使用cscope时出现找不到文件的情况;

命令cscope中的-i参数可以去掉,因为cscope缺省就是从当前目录的cscope.files中查找文件列表。

还有一个简洁的办法实现在当前目录下建立cpp文件和c文件混合的cscope.out;

在~/.bashrc中添加如下alias:

alias mkcscopefile='find `pwd` -name "*.[ch]" -o -name "*.cpp" > cscope.files'
alias mktag='ctags -R;cscope -bR'

然后,在terminal中source ~/.bashrc,就可以使用mkcscopefile;mktag命令来生成cscope.out和tags文件了。

如果路径中含有空格,需要使用sed对生成的cscope.files文件进行处理,命令:

sed -i ‘s/^/"/;s/$/"/' cscope.files


抱歉!评论已关闭.