Bash to zsh
Recently, I migrated from using bash go zsh as most of us did.
chsh -s /bin/zsh easy right :)
But somehow I managed to break my terminal in the process of setting up AndroidStudio. I am not a shell pro but I like to keep couple of adb and git commands as alias, so that I can use AndroidStudio Terminal or System Terminal to perform quick actions. All, I wanted to do was to add the path to android-sdk and platform-tools to the system path so that all the adb commands would be recognized and life would be simple. But somehow I managed to break it.
These are the steps I took to kind of migrate everything my .bash_profile had over to zsh.
Setting up Android SDK and platform path
create
.zshrcfile ->nano ~/.zshrc-
add the path to
zshrc. We can open and edit this file inTextEditoror edit it in the terminal itself like:-
vi ~/.zshrc,then pressiforinsert, paste the path, then:wqforwrite and quit. - something like below:
-
export PATH='$PATH:/~YOUR_HOME/Library/Android/sdk'
export PATH='$PATH:/~YOUR_HOME/Library/Android/sdk/platform-tools'
At this point, most of you might already notice the
mistakein the above snippet. Somehow, having thequotesbroke everything and nothing worked. When I say nothing, I mean thecd,ls,cd ..etc. commands from the system'szsh(/bin/zsh) also didn't work. Once, I delete these two lines, everything would work and I would be where I started, i.e.adbcommands wouldn't work.The key to this was to
removethequotessurrounding the path. Once I removed those, everything started working fine.
export PATH=$PATH:/~YOUR_HOME/Library/Android/sdk
export PATH=$PATH:/~YOUR_HOME/Library/Android/sdk/platform-tools
- One way to verify this is to check the path in the terminal, and the path now should include path to
android-sdkandplatform-tools, this is the commandecho $PATH.
Setting up .zprofile corollary to .bash_profile
- create
.zprofilefile ->nano ~/.zprofile - add the
aliasesto.zprofile. We can open and edit this file inTextEditoror edit it in the terminal itself like:-
vi ~/.zprofile,then pressiforinsert, paste the path, then:wqforwrite and quit.
-
Bonus - some aliases that I use
# Git Commands
alias gf='git fetch'
alias gp='git pull'
alias gs='git status'
alias gcd='git checkout develop' #or master if you have master
# Gradle Commands
alias at='./gradlew assembleDebug assembleAndroidTest'
alias allTest='./gradlew assembleDebug testDebugUnitTest'
alias cbc='./gradlew cleanBuildCache'
alias build='./gradlew build'
alias stop='./gradlew --stop'
alias status='./gradlew --status'
# ADB Commands
alias devs='adb devices'
alias kill='adb kill server'
alias restart='adb restart server'
Please comment if there better ways of doing this and feel free to add more helpful aliases.
Thank you!
Top comments (2)
THANK U BABE ! JUST WHAT I NEEDED <3
You need to use double quotes for variable expansion to work properly.
Single quotes takes the string litterally.