上篇文章:【vim 學(xué)習(xí)系列文章 4 - vim與系統(tǒng)剪切板之間的交互】
下篇文章:【vim 學(xué)習(xí)系列文章 6 – vim 如何從上次退出的位置打開(kāi)文件】文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-662697.html
cscope 過(guò)濾目錄介紹
第一步創(chuàng)建自己的cscope腳本~/.local/bin/cscope.sh
,如下:
function my_cscope()
{
CODE_PATH=`pwd`
echo "$CODE_PATH"
echo "start cscope...."
if [ ! -f "$CODE_PATH/cscope.files" ];then
echo "cscope.files not exist!"
else
rm -f $CODE_PATH/cscope.*
fi
if [ ! -d "$CODE_PATH/rt-thread" ];then
find . \( -path './arch/arc' \
-o -path './arch/alpha' \
-o -path "./arch/blackfin" \
-o -path "./arch/cris" \
-o -path "./arch/h8300" \
-o -path "./arch/ia64" \
-o -path "./arch/m68k" \
-o -path "./arch/microblaze" \
-o -path "./arch/mn10300" \
-o -path "./arch/openrisc" \
-o -path "./arch/powerpc" \
-o -path "./arch/score" \
-o -path "./arch/sparc" \
-o -path "./arch/um" \
-o -path "./arch/x86" \
-o -path "./arch/c6x" \
-o -path "./arch/m32r" \
-o -path "./arch/microblaze" \
-o -path "./arch/nios2" \
-o -path "./arch/powerpc" \
-o -path "./arch/sh" \
-o -path "./arch/um" \
-o -path "./arch/xtensa" \
-o -path "./arch/cris" \
-o -path "./arch/hexagon" \
-o -path "./arch/mips" \
-o -path "./arch/openrisc" \
-o -path "./arch/s390" \
-o -path "./arch/sparc" \
-o -path "./arch/unicore32" \
-o -path "./arch/parisc" \
-o -path "./arch/tile" \
-o -path "./arch/tile" \
-o -path './arch/c6x' \) \
-prune -o -name "*.[chxsS]" -print > cscope.files
else
find . \( -path "./rtos/rt-thread/rt-thread/bsp/mb9*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/at91*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/ess*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/gd3*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/lpc*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/ls*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/mi*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/imx*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/rasp*" \
-o -path "./rtos/rt-thread/packages/packages/iot/*" \
-o -path "./rtos/rt-thread/rt-thread/bsp/stm32/stm32f*" \
-o -path "./bootrom" \
-o -path "./u-boot" \
-o -path "./tools" \) \
-prune -name "*.cc" -o -name "*.[chxsS]" \
-print > cscope.files
fi
echo "cscope -Rbkq -i cscope.files"
cscope -Rbkq -i $PWD/cscope.files > cscope.log 2>&1
echo "cscope finished"
}
my_cscope;
我的這個(gè)腳本首先去區(qū)分當(dāng)前執(zhí)行cscope
命令的目錄是rt-thread
目錄還是linux
目錄,因?yàn)椴煌拇a要過(guò)濾過(guò)目錄不一樣。
此外,還會(huì)通過(guò) 重定向 將cscope
在解析文件cscope.files
過(guò)程中輸出的log
重定向到 cscope.log
方便問(wèn)題問(wèn)題。關(guān)于 find 命令的使用見(jiàn) find 命令高效使用文章
第二步在 ~/.bashrc
中添加 mycscope 命令,添加完后,別忘記執(zhí)行 source ~/.bashrc
。
alias mycscope='source ~/.local/bin/cscope.sh'
第三部測(cè)試效果:
(*^~^*) ~/workbase/cix_linux/linux> mycscope
/home/sam/workbase/linux
start cscope....
cscope -Rbkq -i cscope.files
cscope finished
(*^~^*) ~/workbase/cix_linux/linux> ls
arch COPYING cscope.files cscope.out drivers init Kconfig LICENSES mm samples sound virt
block CREDITS cscope.in.out cscope.po.out fs ipc kernel MAINTAINERS net scripts tools
certs crypto cscope.log Documentation include Kbuild lib Makefile README security usr
從下圖中可以看到通過(guò)cscope命令查找 函數(shù)定義定義時(shí)只顯示了linux/arch 目錄下的幾個(gè)文件,濾除了上文中設(shè)置的那些目錄:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-662697.html
上篇文章:【vim 學(xué)習(xí)系列文章 4 - vim與系統(tǒng)剪切板之間的交互】
下篇文章:【vim 學(xué)習(xí)系列文章 6 – vim 如何從上次退出的位置打開(kāi)文件】
到了這里,關(guān)于【vim 學(xué)習(xí)系列文章 5 - cscope 過(guò)濾掉某些目錄】的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!