From 37f34f8a03677d8c6f7d9232813119bc4168fa92 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Wed, 8 Jul 2015 16:21:18 +0200 Subject: [PATCH] Add shell function --- shell/function.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 shell/function.sh diff --git a/shell/function.sh b/shell/function.sh new file mode 100644 index 0000000..3921782 --- /dev/null +++ b/shell/function.sh @@ -0,0 +1,60 @@ + +mgrep () { + find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@" +} + +cgrep () { + find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -print0 | xargs -0 grep --color -n "$@" +} + +jgrep () { + find . -name .repo -prune -o -name .git -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@" +} + +cjgrep () { + find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' -o -name "*.java" \) -print0 | xargs -0 grep --color -n "$@" +} + +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 +} + +gettop () +{ + local TOPFILE=build/core/envsetup.mk; + if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ]; then + echo $TOP; + else + if [ -f $TOPFILE ]; then + PWD= /bin/pwd; + else + local HERE=$PWD; + T=; + while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do + \cd ..; + T=`PWD= /bin/pwd`; + done; + \cd $HERE; + if [ -f "$T/$TOPFILE" ]; then + echo $T; + fi; + fi; + fi +} + +croot () +{ + T=$(gettop); + if [ "$T" ]; then + \cd $(gettop); + else + echo "Couldn't locate the top of the tree. Try setting TOP."; + fi +} + +apush() { + adb root && adb wait-for-device && adb remount && adb wait-for-device && adb push $1 $2 +}