This function really helps as a cscope alternative. check for any variable as "f "
function f() {
local i o m
set -f
test "$ffo" || ffo='! -iname tags'
for i in "$@"; do
case "$i" in
c) ffo='-iname *.[chs]' ;;
h) ffo='-iname *.[h]' ;;
x) ffo='-iregex .*\.[chs][xp+]?[xp+]?' ;;
p) ffo='-iname *.php*' ;;
q) ffo='! -iname tags' ;;
-*) o="$o $i" ;;
*) m="$m $i" ;;
esac
done
test "$m" || return
find . $ffo -type f -print0 \
| xargs -0 grep --colour=always --binary-file=without-match -n $o "${m# }" \
| tee ~/.ff~
set +f
}
function v() {
local cmd
test -s ~/.ff~ || return
if [ "$*" ]; then
grep "$*" ~/.ff~ > ~/.ff- || return
cmd="vim +`head -1 ~/.ff- | cut -d: -f2` `head -1 ~/.ff- | cut -d: -f1 | uniq`"
history -s $cmd
$cmd
else
perl -pe 's/\033[^a-z]*[a-z]//g' ~/.ff~ > ~/.ff
vim -q ~/.ff -c :cw5
fi
}
alias vv='cat ~/.ff~'
No comments:
Post a Comment