Skip to content

Instantly share code, notes, and snippets.

@guelo
Forked from cgould/.bash_profile
Created March 21, 2018 19:33
Show Gist options
  • Save guelo/d046d793bd476797f297a7f5c7ef8315 to your computer and use it in GitHub Desktop.
Save guelo/d046d793bd476797f297a7f5c7ef8315 to your computer and use it in GitHub Desktop.
export PS1="\u:$ "
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/26.0.2:~/scripts:.:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:/usr/local/share/npm/bin:$HOME/bin/gsutil:$HOME/.rvm/bin"
export NODE_PATH="/usr/local/lib/node_modules"
export EDITOR="subl -w"
export GRADLE_OPTS="-Dorg.gradle.daemon=true"
export HISTTIMEFORMAT="%m-%d %T "
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
export CHROME_BIN=/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
hi() {
history | grep $1
}
alias profile="cat ~/.bash_profile"
alias loadprof="source ~/.bash_profile"
alias edprof="subl ~/.bash_profile"
alias showfiles='defaults write com.apple.finder AppleShowAllFiles YES;killall Finder /System/Library/CoreServices/Finder.app'
alias hidefiles='defaults write com.apple.finder AppleShowAllFiles NO;killall Finder /System/Library/CoreServices/Finder.app'
alias src="cd ~/src"
alias ot="cd ~/src/opentable-android/"
alias gc="cd ~/src/guest-center-android/"
alias apk="cd ~/src/opentable-android/app/build/outputs/apk/com/debug"
alias gcapk="cd ~/src/guest-center-android/app/build/outputs/apk"
alias gcapkr="cd ~/src/guest-center-android/app/build/outputs/apk/release"
alias gcapkd="cd ~/src/guest-center-android/app/build/outputs/apk/debug"
alias dl="cd ~/Downloads"
alias gradle-profiler="/Users/cgould/src/gradle-profiler/build/install/gradle-profiler/bin/gradle-profiler"
alias uia="uiautomatorviewer &"
alias sp="adb shell cat /data/data/com.opentable/shared_prefs/*.xml"
alias adbr="adb kill-server && adb devices"
em() {
~/Library/Android/sdk/emulator/emulator -avd $1 &> /dev/null &
}
alias nex5x="em Nexus_5X_API_25"
alias pix="em Pixel_API_25"
tdl() {
adb shell am start -W -a android.intent.action.VIEW $1
}
logcat() {
adb logcat | grep "$(adb shell ps | grep com.opentable | awk '{ print $2}')"
}
alias regid="adb shell cat /data/data/com.opentable/shared_prefs/GCM_PREFS.xml | grep reg | sed -e 's/<[^>]*>//g' |sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//' | pbcopy && pbpaste"
alias gittags="git push --tags"
alias gitprune="git remote prune origin"
alias gitfixtime="GIT_COMMITTER_DATE=\"`date`\" git commit --amend --date \"`date`\""
gitrelease() {
git tag --contains $1 | sort | awk 'NR==1{print}'
}
relnotes() {
git log $1..$2 | grep "\[CYL" | sed 's/.*\[\(.*\)\].*/\1/' | sort -u | tr '\n' ', ' | sed 's/,$//' | pbcopy && pbpaste
}
alias dev1="adb devices | awk 'NR==2' | awk '{print \$1}'"
alias dev2="adb devices | awk 'NR==3' | awk '{print \$1}'"
alias dev3="adb devices | awk 'NR==4' | awk '{print \$1}'"
alias dev4="adb devices | awk 'NR==5' | awk '{print \$1}'"
alias adbfixdate='adb shell date $(date +%m%d%H%M%Y)'
alias testcode="./gradlew assembleComDebug testComDebugUnitTest connectedComDebugAndroidTest"
alias clean="gradlew clean"
adbrestart() {
adb kill-server
adb start-server
adb devices
}
alias sim="adb shell getprop gsm.sim.operator.iso-country"
simau() {
adb $@ shell setprop gsm.sim.operator.iso-country au
}
simus() {
adb $@ shell setprop gsm.sim.operator.iso-country us
}
simuk() {
adb $@ shell setprop gsm.sim.operator.iso-country uk
}
lcom() {
adb $@ shell am start -n com.opentable/com.opentable.activities.StartActivity
}
simde() {
adb $@ shell setprop gsm.sim.operator.iso-country de
}
simmx() {
adb $@ shell setprop gsm.sim.operator.iso-country mx
}
simca() {
adb $@ shell setprop gsm.sim.operator.iso-country ca
}
simja() {
adb $@ shell setprop gsm.sim.operator.iso-country ja
}
simjp() {
simja
}
simnl() {
adb $@ shell setprop gsm.sim.operator.iso-country nl
}
gpson() {
genyshell -c "gps setstatus enabled"
genyshell -c "gps setlatitude 37.5"
genyshell -c "gps setlongitude -122.5"
}
alias nex5=" /Applications/Genymotion.app/Contents/MacOS/gmtool admin start \`VBoxManage list vms | grep 'Nexus 5 ' | sed -e 's/.*{\(.*\)}/\1/'\` > /dev/null 2>&1 &"
alias nex5x24=" /Applications/Genymotion.app/Contents/MacOS/gmtool admin start \`VBoxManage list vms | grep 'Nexus 5X.*24' | sed -e 's/.*{\(.*\)}/\1/'\` > /dev/null 2>&1 &"
alias nex5x23=" /Applications/Genymotion.app/Contents/MacOS/gmtool admin start \`VBoxManage list vms | grep 'Nexus 5X.*23' | sed -e 's/.*{\(.*\)}/\1/'\` > /dev/null 2>&1 &"
alias nex6=" /Applications/Genymotion.app/Contents/MacOS/gmtool admin start \`VBoxManage list vms | grep 'Nexus 6' | sed -e 's/.*{\(.*\)}/\1/'\` > /dev/null 2>&1 &"
alias nex9=" /Applications/Genymotion.app/Contents/MacOS/gmtool admin start \`VBoxManage list vms | grep 'Nexus 9' | sed -e 's/.*{\(.*\)}/\1/'\` > /dev/null 2>&1 &"
alias adbclear="adb shell pm clear com.opentable"
alias myip="ifconfig en0 | grep inet | grep -v inet6 | awk '{print \$2}' | pbcopy && pbpaste"
adbstop() {
adb $@ shell am force-stop com.opentable
}
alias adbreset="adbstop && adbclear"
alias adbtasks="adb shell dumpsys activity activities | grep 'Task id\|Hist #\|state\='"
alias adbdb="adb shell am set-debug-app -w --persistent com.opentable"
alias adbdbc="adb shell am clear-debug-app"
alias adbdbgc="adb shell am set-debug-app -w --persistent com.opentable.guestcenter.beta"
alias adberr="adb logcat -v time -d | grep AndroidRuntime"
alias trackon="adb shell am broadcast -a com.opentable.intent.action.EDIT_FEATURE_TOGGLES -n com.opentable/.helpers.FeatureTogglesReceiver --ez analyticsTracking true"
alias trackoff="adb shell am broadcast -a com.opentable.intent.action.EDIT_FEATURE_TOGGLES -n com.opentable/.helpers.FeatureTogglesReceiver --ez analyticsTracking false"
alias gcmon="adb shell am broadcast -a com.opentable.intent.action.EDIT_FEATURE_TOGGLES -n com.opentable/.helpers.FeatureTogglesReceiver --ez gcmRegistration true"
alias gcmoff="adb shell am broadcast -a com.opentable.intent.action.EDIT_FEATURE_TOGGLES -n com.opentable/.helpers.FeatureTogglesReceiver --ez gcmRegistration false"
alias owlon="adb shell am broadcast -a com.opentable.intent.action.EDIT_FEATURE_TOGGLES -n com.opentable/.helpers.FeatureTogglesReceiver --ez onlineWaitlist true"
alias owloff="adb shell am broadcast -a com.opentable.intent.action.EDIT_FEATURE_TOGGLES -n com.opentable/.helpers.FeatureTogglesReceiver --ez onlineWaitlist false"
alias slon="adb shell am broadcast -a com.opentable.intent.action.TOGGLE_AB_TESTS -n com.opentable/.helpers.FeatureTogglesReceiver --ei SMARTLOCK_MANAGER 1"
alias sloff="adb shell am broadcast -a com.opentable.intent.action.TOGGLE_AB_TESTS -n com.opentable/.helpers.FeatureTogglesReceiver --ei SMARTLOCK_MANAGER 0"
alias gitb="git rev-parse --abbrev-ref HEAD"
adbv() {
aapt dump badging $1 | head -3
}
cl() { history -p '!!'|tr -d \\n|pbcopy; }
list_tests() {
awk '/public enum Test/{flag=1;next}/\;/{flag=0}flag' ~/src/opentable-android/app/src/main/java/com/opentable/utils/ABTests.java | grep -o '.*(' | sed 's/(//'
}
teston() {
feature=$1
shift
cmd="adb $@ shell am broadcast -a com.opentable.intent.action.TOGGLE_AB_TESTS -n com.opentable/.helpers.FeatureTogglesReceiver --ei $feature 1"
execcmd $cmd
}
testoff() {
feature=$1
shift
cmd="adb $@ shell am broadcast -a com.opentable.intent.action.TOGGLE_AB_TESTS -n com.opentable/.helpers.FeatureTogglesReceiver --ei $feature 0"
execcmd $cmd
}
featureon() {
feature=$1
shift
cmd="adb $@ shell am broadcast -a com.opentable.intent.action.EDIT_FEATURE_TOGGLES -n com.opentable/.helpers.FeatureTogglesReceiver --ez $feature true"
execcmd $cmd
}
featureoff() {
feature=$1
shift
cmd="adb $@ shell am broadcast -a com.opentable.intent.action.EDIT_FEATURE_TOGGLES -n com.opentable/.helpers.FeatureTogglesReceiver --ez $feature false"
execcmd $cmd
}
execcmd() {
echo $@
eval $@
}
dcom() {
cmd="deploy_app com.opentable debug $@"
execcmd $cmd
}
upcom() {
cmd="upgrade_app com.opentable debug $@"
execcmd $cmd
}
ucom() {
cmd="adb $@ uninstall com.opentable"
execcmd $cmd
}
bdcom() {
cmd="build_and_deploy_app assembleComDebug com.opentable debug $@"
execcmd $cmd
}
bcom() {
cmd="build_app assembleComDebug"
execcmd $cmd
}
build_and_deploy_app() {
pushd .
cmd="build_app $@"
execcmd $cmd
shift
cmd="deploy_app $@"
execcmd $cmd
popd
}
deploy_app() {
pushd .
domain=$1
flavor=$2
shift
shift
apk
execcmd "adb $@ uninstall $domain"
#execcmd "adb $@ install $domain-$flavor.apk | grep -v '^\['"
execcmd "adb $@ install $domain-$flavor.apk"
date
popd
}
deploy_gc() {
pushd .
gcapk
#execcmd "adb uninstall com.opentable.guestcenter"
execcmd "adb install -r -t debug/com.opentable.guestcenter.beta-1.apk"
date
popd
}
upgrade_app() {
pushd .
domain=$1
flavor=$2
shift
shift
apk
# execcmd "adb $@ install -r $domain-$flavor.apk | grep -v '^\['"
execcmd "adb $@ install -r $domain-$flavor.apk"
date
popd
}
build_app() {
pushd .
ot
echo "*************************"
branch=`gitb`
echo "Starting build on branch $branch"
echo "*************************"
cmd="gradlew $1"
execcmd $cmd
date
popd
}
build_gc() {
pushd .
gc
echo "*************************"
branch=`gitb`
echo "Starting build on branch $branch"
echo "*************************"
cmd="gradlew assembleDebug -PskipProguard=true"
execcmd $cmd
date
popd
}
############### BEGIN APPIUM TEST STUFF #########################
runtests() {
pushd .
cd ~/src/opentable-android-automation
DEVICE=$(adb devices | awk 'FNR == 2 { print $1}')
echo "running on $DEVICE"
cmd="node runTests.js --device-id $DEVICE --app-file ~/src/opentable-android/app/build/outputs/apk/com.opentable-debug.apk --tags $1"
execcmd $cmd
popd
}
dbgtests() {
pushd .
cd ~/src/opentable-android-automation
DEVICE=$(adb devices | awk 'FNR == 2 { print $1}')
echo "running on $DEVICE"
cmd="node runTests.js --device-id $DEVICE --app-file ~/src/opentable-android/app/build/outputs/apk/com.opentable-debug.apk --tags $1 --debug"
execcmd $cmd
popd
}
alias ka="ps -A | grep /usr/local/bin/appium | grep -v grep | awk '{print $0}' | xargs kill -9"
alias ka2="lsof -Pi :4134 | awk 'FNR == 2 { print $2}' | xargs kill -9"
alias rt="ka && ka2"
############### END APPIUM TEST STUFF #########################
alias gloc="adb shell pm grant com.opentable android.permission.ACCESS_FINE_LOCATION"
alias rloc="adb shell pm revoke com.opentable android.permission.ACCESS_FINE_LOCATION"
alias gphone="adb shell pm grant com.opentable android.permission.READ_PHONE_STATE"
alias rphone="adb shell pm revoke com.opentable android.permission.READ_PHONE_STATE"
alias gaccts="adb shell pm grant com.opentable android.permission.GET_ACCOUNTS"
alias raccts="adb shell pm revoke com.opentable android.permission.GET_ACCOUNTS"
alias gcam="adb shell pm grant com.opentable android.permission.CAMERA"
alias rcam="adb shell pm revoke com.opentable android.permission.CAMERA"
gall() {
gloc
gphone
gaccts
gcam
}
rall() {
rloc
rphone
raccts
rcam
}
alias bdlcom="bdcom && lcom"
alias dlcom="dcom && lcom"
alias dcom1="dcom -s \`dev1\`"
alias dcom2="dcom -s \`dev2\`"
alias lcom1="lcom -s \`dev1\`"
alias lcom2="lcom -s \`dev2\`"
alias bulcom="bcom && upcom && lcom"
alias kcom="adb shell am force-stop com.opentable"
alias ulcom="upcom && lcom"
alias bgc="build_gc"
alias dgc="deploy_gc"
alias lgc="adb shell am start -n com.opentable.guestcenter.beta/com.opentable.guestcenter.ui.start.StartActivity"
alias dlgc="dgc && lgc"
alias bdgc="bgc && dgc"
alias bdlgc="bdgc && lgc"
alias kgc="adb shell am force-stop com.opentable.guestcenter.beta"
alias ugc="adb uninstall com.opentable.guestcenter.beta"
alias gcv="adb shell dumpsys package com.opentable.guestcenter | grep versionName"
alias gcbv="adb shell dumpsys package com.opentable.guestcenter.beta | grep versionName"
alias adbdbgc="adb shell am set-debug-app -w --persistent com.opentable.guestcenter.beta"
alias adbdbgcc="adb shell am clear-debug-app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment