From fb60eb255f538ffbe9c5f948db37c2e94447cde5 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Wed, 25 Nov 2015 11:35:22 +0100 Subject: [PATCH] [zsh] more grep function --- .zsh/30_alias.zsh | 2 +- .zsh/40_function.zsh | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.zsh/30_alias.zsh b/.zsh/30_alias.zsh index 2249471..45f8b2b 100644 --- a/.zsh/30_alias.zsh +++ b/.zsh/30_alias.zsh @@ -21,7 +21,7 @@ alias xte='nohup xterm &' # xte lancera un xterm qui ne se fermera pas si on fer alias minicom='minicom -c on' alias vims='vim --servername vimserver' alias vimo='vim --servername vimserver --remote-tab' -alias agrep='grep --exclude=.git --exclude-dir=out --exclude-dir=prebuilts --exclude-dir=docs' +alias agrep='grep --exclude=.git --exclude-dir=out --exclude-dir=prebuilts --exclude-dir=docs --exclude=tags --exclude=cscope.out' #Extension Alias alias -s html=$BROWSER diff --git a/.zsh/40_function.zsh b/.zsh/40_function.zsh index d43e21b..6de1aaf 100755 --- a/.zsh/40_function.zsh +++ b/.zsh/40_function.zsh @@ -110,11 +110,25 @@ resgrep () { for dir in `find . -name .repo -prune -o -name .git -prune -o -name res -type d` do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@" - done + done } -gettop () -{ +sgrep() { + find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cc|cpp|S|java|xml|sh|mk|aidl)' -print0 | xargs -0 grep --color -n "$@" +} + +mangrep() { + find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@" +} + +sepgrep() { + find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d -print0 | xargs -0 grep --color -n -r --exclude-dir=\.git "$@" +} + + + +gettop () +{ local TOPFILE=build/core/envsetup.mk; if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ]; then echo $TOP;