Skip to content

Instantly share code, notes, and snippets.

@michchan
Last active July 5, 2022 11:58
Show Gist options
  • Save michchan/827a1dd0c4b46bfb6974db728b1e9bfb to your computer and use it in GitHub Desktop.
Save michchan/827a1dd0c4b46bfb6974db728b1e9bfb to your computer and use it in GitHub Desktop.
.zshrc for Frontend/Fullstack Dev
#### Git branch on terminal
# Reference: https://stackoverflow.com/questions/17333531/how-can-i-display-the-current-branch-and-folder-path-in-terminal
parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF=$'\e[0m'
COLOR_USR=$'\e[38;5;243m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
NEWLINE=$'\n'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '
#### Node Version Manager
# Reference: https://github.com/nvm-sh/nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# Added by serverless binary installer
export PATH="$HOME/.serverless/bin:$PATH"
# tabtab source for packages
# uninstall by removing these lines
[[ -f ~/.config/tabtab/__tabtab.zsh ]] && . ~/.config/tabtab/__tabtab.zsh || true
#### Show PWD on the current terminal title
# Reference: https://apple.stackexchange.com/questions/90725/for-iterm2-how-do-i-make-the-working-directory-appear-in-the-window-title
if [ $ITERM_SESSION_ID ]; then
precmd() {
echo -ne "\033]0;${PWD##*/}\007"
}
fi
#### React Native ANDROID_HONE environment variable
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
#### Python 3
export PATH=$HOME/Library/Python/3.9/bin/:$PATH
#### Java Home
# Run `/usr/libexec/java_home -V` to list installed java versions
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
#### Custom Aliases
alias src='source ~/.zshrc'
alias ngrok='/Applications/ngrok'
### Git
alias g='git'
alias glt='git log --oneline --decorate --graph --all'
alias glta='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --all'
### node / nvm
alias nvmdef='nvm use default'
alias rmnm='rm -rf node_modules'
### yarn
alias y='yarn'
alias yi='yarn install'
alias yif='yarn install --force'
alias ycc='yarn cache clean'
alias ya='yarn add'
alias yad='yarn add --dev'
alias yr='yarn run'
alias yt='yarn run test'
alias ytu='yarn run test -u'
alias yvers='f() { yarn info $1 versions };f'
alias ydv='yarn dev'
alias ydv:mk='yarn dev:mock'
alias yst='yarn start'
alias yst:lc='yarn start:local'
alias yst:dv='yarn start:dev'
alias yst:pr='yarn start:prod'
alias yb='yarn build'
alias ylt='yarn lint'
alias yltfx='yarn lint --fix'
alias ytscw='yarn tsc --watch --noemit'
# For ttsc package
alias yttscw='yarn ttsc --watch --noemit'
alias ydp='yarn deploy'
alias ycp='yarn compile'
# For `yarn-audit-fix`
alias yauditfx='npx yarn-audit-fix'
# List npm scripts with JS
alias jqscripts='jq .scripts package.json'
### snyk
alias sk="snyk"
alias skt="snyk test"
alias skw="snyk wizard"
### For `standard-version` npm library
alias yrelease:patch="yarn run release --release-as patch"
alias yrelease:minor="yarn run release --release-as minor"
alias yrelease:major="yarn run release --release-as major"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment