-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc
237 lines (201 loc) · 7.59 KB
/
bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
alias ls='ls -G'
alias vim='nvim'
alias vi='nvim'
alias sn='vi ~/SN/README'
alias nexus='/Users/ali.shah/Library/Android/sdk/tools/emulator -avd Nexus_5X_API_26 &'
alias pixel='/Users/ali.shah/Library/Android/sdk/emulator/emulator64 -avd Pixel_XL_API_27'
set -o vi
#export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
export PATH="$PATH:$HOME/.bin"
export EDITOR="nvim"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h:\[$(tput sgr0)\]\[\033[38;5;34m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\] \\$ \[$(tput sgr0)\]"
alias vimdiff="nvim -d"
#### Android Setup guide
#export CLIENT_TOOLS_ROOT=$HOME/Library/Android/sdk
#export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
#export ANDROID_SDK_HOME=$HOME/Library/Android/sdk
#export ANDROID_HOME=$HOME/Library/Android/sdk
# Export ANDROID_NDK_ROOT to tell the makefiles where it can
# find the cross-compilation tools.
#export ANDROID_NDK_ROOT=$HOME/Library/Android/sdk/ndk-bundle/android-ndk-r11c
#export ANDROID_NDK_HOME=$HOME/Library/Android/sdk/ndk-bundle/android-ndk-r11c
# Update your path so you can call adb, android and other
# binaries in the SDK.
export PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_NDK_ROOT
# This this export of FLX_TARGET tells the Makefiles to build
# Android - it's the only target we use these days.
export FLX_TARGET=Android
#Android requires JDK8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
# This export of SECURITY_CORE_PATH tells the makefiles where it
# can find the security project in order to build the last version
# of the library.
export SECURITY_CORE_PATH=$HOME/Projects/security
#### END Android Setup guide
alias ..='cd ..'
alias client='cd ~/ws/sn_client/Android'
alias partners='cd ~/ws/android/apps/personal/partners/'
alias features='cd ~/ws/android/apps/personal/features/'
alias uninstallSN='adb uninstall com.att.mobilesecurity'
#alias phase2='amoc_reset 0000000003; echo -n "Uninstalling... "; adb uninstall com.att.mobilesecurity; echo -n "Instaling Phase2... "; adb install ~/Downloads/apk/SmartNetwork-AmocPhase2-debug-2.0.10-9686717.apk; echo -e "\n\n"'
alias phase2='amoc_reset 0000000003; echo -n "Uninstalling... "; adb uninstall com.att.mobilesecurity; echo -n "Instaling Phase2... "; adb install ~/Downloads/APKs/SmartNetwork-AmocPhase2-debug-2.0.11-1fbc6dc.apk; echo -e "\n\n"'
alias phase3='echo -n "Installing Phase3... "; date; echo ""; adb install -r ~/ws/sn_client/Android/SmartNetwork/build/apk/SmartNetwork-AmocPhase3-debug.apk;'
alias phase3_offical='echo -n "Installing Official Phase3... "; date; echo ""; adb install -r ~/Downloads/APKs/SmartNetwork-AmocPhase3-debug-3.0-8ef01e0.apk;'
alias attsnui='vi ~/ws/sn_client/Android/partners/attsn_ui/src/main/java/com/lookout/plugin/ui/attsn/AttSnUiPluginModule.java'
alias pbc='pbcopy'
alias pbp='pbpaste'
alias debug="cd ~/ws/android/apps/personal/SmartNetwork/src/debug/java/com/att/mobilesecurity/application/"
alias main="cd ~/ws/android/apps/personal/SmartNetwork/src/main/java/com/att/mobilesecurity/application/"
alias release="cd ~/ws/android/apps/personal/SmartNetwork/src/release/java/com/att/mobilesecurity/application/"
export FZF_DEFAULT_COMMAND='(git ls-tree -r --name-only HEAD || find . -path "*/\.*" -prune -o -type f -print -o -type l -print | sed s/^..//) 2> /dev/null'
export FZF_DEFAULT_OPTS="--height 75% --reverse --border --no-mouse"
fz () {
FILE=$(fzf)
if [[ "$?" == 0 ]]; then
eval vi $FILE
fi
}
fzd () {
if [[ $1 != "" ]];
then
eval cd $(dirname "$1")
else
FILE=$(fzf --no-mouse)
if [[ "$?" == 0 ]]; then
eval cd $(dirname "$FILE")
fi
fi
}
diffz () {
FILE=$(fzf)
if [[ "$?" == 0 ]]; then
eval git difftool HEAD^ HEAD $FILE
fi
}
vicommit() {
COMMIT=$1
FILE=$(git show --pretty="" --name-only $COMMIT | fzf)
if [[ "$?" == 0 ]]; then
eval vi $FILE
fi
}
find_apk () {
REL=$1
TC=$2
file=$TC/$REL/$(basename $TC | cut -c15- | sed "s/Market/market-$REL/").apk;
echo $file
}
install_release_apk () {
file=$(find_apk release $1)
echo "Attempt to install $file..."
adb install $file
}
git_status_vi() {
COMMIT=$1
echo "COMMIT IS: $1"
if [[ -z $COMMIT ]]
then
# FILE=$(git status -u | egrep 'modified|new\ file' | fzf)
# FILE=$(git status -u | grep 'modified|new\ file' | fzf)
FILE=$(git status -u --porcelain | fzf)
if [[ $? == 0 ]];
then
# FILE=$(echo $FILE | sed 's/.*: //')
FILE=$(echo $FILE | sed 's/^.* //')
eval vi "$FILE"
fi
else
git_show_vi $COMMIT
fi
}
alias gsv='git_status_vi'
git_show_vi () {
COMMIT=$1
if [[ $COMMIT == "" ]]; then
$COMMIT="HEAD"
fi
echo "Looking up : $COMMIT"
FILE=$(git show --name-only $COMMIT |fzf);
if [[ $? == 0 ]];
then
eval vi "$FILE"
fi
}
function fuzz () {
FILE=$(fzf)
export FZ_FILE=$FILE
echo $FZ_FILE
}
alias git_latest_head='git rev-parse HEAD | cut -c-7'
alias android_log='adb logcat | grep "Lookout : \[" | egrep -v BooleanGate\|BatterySensor\|InvestigationMetricTracker\|dalvik-cache\|FirmwareInvestigator\|PaperDelivery\|NewsroomService\|AppScanListener\|SecurityDB\|ZipAnomalyDetected\|HasAssessment\|ScanMetricsListener\|ZipFileInputStream\|FilesystemScanManagerScanner\|ResourceDataTable\|ScannableManifest\|ContainsPattern\|INotify.startMonitoring\|LocalScanner\|BaseApkScanner\|Id3TagValidationHeuristic'
function checkout() {
name=$1
location=$2
git clone [email protected]:lookout/$name.git $location
cd $location
scp -P 29418 gerrit:hooks/commit-msg .git/hooks
git remote set-url --push origin no_push
git remote add -f gerrit ssh://[email protected]:29418/$name
}
apk_fz () {
FILE=$(fzf)
echo "GOT: $FILE"
if [[ "$?" == 0 ]]; then
adb install "$FILE"
fi
}
files_changed () {
COMMIT=$1
if [[ $COMMIT == "" ]];
then
echo "checking HEAD"
COMMIT="HEAD^"
fi
echo git diff --name-only $COMMIT
}
ls_apk () {
find ./apps/personal/SmartNetwork/build -name *.apk 2>/dev/null
find ./apps/personal/SmartBusiness/build -name *.apk 2>/dev/null | while read line; do ls -l $line; done;
find ./apps/personal/Phoenix/build -name *.apk 2>/dev/null
}
clean_apk() {
ls_apk | while read line; do rm "$line"; done
}
apks () {
HASH=$(git log | head -1 | cut -c 8-14)
echo "Looking for $HASH"
find ./apps/personal/SmartNetwork/build -name *$HASH*.apk -exec ls -latr {} \; 2>/dev/null
find ./apps/personal/SmartBusiness/build -name *$HASH*.apk -exec ls -latr {} \; 2>/dev/null
find ./apps/personal/Phoenix/build -name *$HASH*.apk -exec ls -latr {} \; 2>/dev/null
find ./apps/personal/LookoutPersonal/build -name *$HASH*.apk -exec ls -latr {} \; 2>/dev/null
}
select_apk () {
SELECTED=$(apks | grep -v unsigned | fzf | awk '{print $NF}')
echo "$SELECTED"
}
adb_connect() {
adb connect 192.168.1.19:5555
}
install_apk() {
APK=$(select_apk)
echo "Installing: $APK"
adb install -r "$APK"
}
sha256sum() {
echo -n $1 | shasum -a 256
}
pick_command() {
cmd=$(echo -e \
"./gradlew :apps:personal:features:attsn:testDebugUnitTest
./gradlew :apps:personal:features:attsn:checkstyle
./gradlew :apps:personal:partners:attsn_ui:testDebugUnitTest
./gradlew :apps:personal:partners:attsn_ui:checkstyle
./gradlew :apps:personal:partners:att_common_ui:testDebugUnitTest
./gradlew :apps:personal:partners:att_common_ui:checkstyle
./gradlew :apps:personal:features:attsn:checkstyle" | fzf)
echo "$cmd"
$cmd
}