Skip to content

Instantly share code, notes, and snippets.

@MrHadiSatrio
Last active March 29, 2024 03:09
Show Gist options
  • Save MrHadiSatrio/03a71dd513ff555e29942f465ae8ffbb to your computer and use it in GitHub Desktop.
Save MrHadiSatrio/03a71dd513ff555e29942f465ae8ffbb to your computer and use it in GitHub Desktop.
Hadi's .profile for ZSH
# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"
alias zeep="code -w ~/.zprofile; source ~/.zprofile"
# Set PATH, aliases, etc., for JEnv.
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
alias java8="jenv shell zulu64-1.8.0.352"
alias java11="jenv shell zulu64-11.0.17"
alias java17="jenv shell zulu64-17.0.7"
jenv global zulu64-17.0.7
# Set PATH, aliases, etc., for rbenv.
eval "$(rbenv init - zsh)"
alias ruby3="rbenv shell 3.1.2"
rbenv global 3.1.2
# Set PATH, aliases, etc., for nodeenv.
eval "$(nodenv init -)"
alias node14="nodenv shell 14.20.1"
nodenv global 14.20.1
# Set PATH, aliases, etc., for Android SDK.
export ANDROID_HOME="/opt/homebrew/share/android-sdk"
export PATH="$ANDROID_HOME/platform-tools:$PATH"
alias adsh="$ANDROID_HOME/platform-tools/adb shell"
alias addl="$ANDROID_HOME/platform-tools/adb shell am start -a android.intent.action.VIEW"
alias adlc="$ANDROID_HOME/platform-tools/adb logcat -b crash"
alias adia="$ANDROID_HOME/platform-tools/adb install"
alias adua="$ANDROID_HOME/platform-tools/adb uninstall"
alias adka="$ANDROID_HOME/platform-tools/adb shell am force-stop"
alias adpl="$ANDROID_HOME/platform-tools/adb pull"
# Set aliases, functions for Git.
alias gtco="git checkout"
alias gtcb="git checkout -b"
alias gtcd="git checkout develop"
alias gtsc="git stash"
alias gtpl="git pull"
alias gtpu="git push"
alias gtrh="git reset --hard HEAD"
alias gtro="git reset --hard origin"
alias gtri="git rebase -i"
alias gtrc="git rebase --continue"
alias gtra="git rebase --abort"
function gtfc() { git branch | grep $1 | xargs git checkout }
function gtfd() { git branch | grep $1 | xargs git branch -D }
# Set aliases for Gradle Wrapper
alias gwca="./gradlew check"
alias gwaa="./gradlew assemble"
alias gwba="./gradlew build"
# Set aliases for thefuck.
eval $(thefuck --alias)
alias damn="fuck"
alias shit="fuck"
# Source Gojek-specific profile
source ~/.zprofile_gojek &> /dev/null
# Function to loop-launch a given Android app
function adts() {
PACKAGE_ID=$1 # Package ID of the app
REPEAT_COUNT=$2 # How many times the launch trace should be captured. Ideally not less than 3.
echo "Force-stopping app \"$PACKAGE_ID\"."
$ANDROID_HOME/platform-tools/adb shell am force-stop $PACKAGE_ID &> /dev/null
echo "Launch-looping app \"$PACKAGE_ID\"."
echo "Cleaning up existing trace files."
$ANDROID_HOME/platform-tools/adb shell rm -rf /storage/emulated/0/Android/data/$PACKAGE_ID/files/traces/ &> /dev/null
COUNTER=1
until [ $COUNTER -gt $REPEAT_COUNT ]
do
echo "Loop $COUNTER of $REPEAT_COUNT."
sleep 16
$ANDROID_HOME/platform-tools/adb shell monkey -p $PACKAGE_ID 1 &> /dev/null
sleep 16
$ANDROID_HOME/platform-tools/adb shell am force-stop $PACKAGE_ID &> /dev/null
((COUNTER++))
done
echo "Extracting trace files from \"$PACKAGE_ID\"'s external files directory."
$ANDROID_HOME/platform-tools/adb pull /storage/emulated/0/Android/data/$PACKAGE_ID/files/traces/ ~/Downloads/ &> /dev/null
echo "Cleaning up extracted trace files."
$ANDROID_HOME/platform-tools/adb shell rm -rf /storage/emulated/0/Android/data/$PACKAGE_ID/files/traces/ &> /dev/null
}
# Function to pull the changes from this Gist
function envp() {
curl https://gist.githubusercontent.com/MrHadiSatrio/03a71dd513ff555e29942f465ae8ffbb/raw/8f27b3f35b5f8e1732822dfe59916218e3b0a362/.zprofile > ~/.zprofile
}
# Function to setup my preferred environment on a Mac (with Apple Silicon)
function envi() {
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
source ~/.zprofile &> /dev/null
brew tap homebrew/cask-versions
brew update
# Install MAS (CLI for the Mac App Store)
brew install mas
# Install fonts
curl -o ~/Library/Fonts/ComicMono.ttf https://dtinth.github.io/comic-mono-font/ComicMono.ttf
# Install SDKs, env. managers, for Java
brew install zulu zulu17 zulu11 zulu8 jenv
source ~/.zprofile &> /dev/null
jenv add /Library/Java/JavaVirtualMachines/zulu-19.jdk/Contents/Home/
jenv add /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home/
jenv add /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/
jenv add /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/
# Install SDKs, env. managers, for Ruby
brew install rbenv ruby-build
source ~/.zprofile &> /dev/null
rbenv install 3.1.2
# Install SDKs, env. managers, for Node JS
brew install nodenv
source ~/.zprofile &> /dev/null
nodenv install 14.20.1
# Install SDKs for Android
brew install android-sdk
brew install --cask android-file-transfer
source ~/.zprofile &> /dev/null
touch ~/.android/repositories.cfg
sdkmanager "build-tools;33.0.0" "platform-tools" "platforms;android-33" "sources;android-33" "system-images;android-33;google_apis;arm64-v8a" "system-images;android-33;google_apis_playstore;arm64-v8a" "system-images;android-21;google_apis;arm64-v8a"
# Install development tools
brew install --cask intellij-idea-ce visual-studio-code-insiders android-studio-preview-canary
brew install --cask charles insomnia
brew install cloc
# Install communication tools
brew install --cask slack whatsapp zoom
mas install 1482454543 # Twitter
# Install productivity tools
brew install arc
# Install general tools
brew install z thefuck
brew install --cask aldente
# Ensure everything is up-to-date
brew update
brew upgrade
source ~/.zprofile &> /dev/null
# Prepare common directories
mkdir -p ~/Projects/Dart
mkdir -p ~/Projects/JavaScript
mkdir -p ~/Projects/Kotlin
mkdir -p ~/Projects/Ruby
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment