React Native Developers - Save your Time with these 24 Terminal Tricks
I am a React Native developer. During my day-to-day work, I found these most useful terminal tricks to be super time savers for me, so I’m sharing. Enjoy!
This list is mine .zshrc
related to react-native
development
General
- Open
WebStorm
from the current directory
alias ws=”open -a /Applications/WebStorm.app .
- Print all
scripts
section inpackage.json
(jq
is required)
alias scripts=”cat package.json | jq -r ‘.scripts’”
- Edit
README.md
(using MacDown)
alias editReadme=”open -a /Applications/MacDown.app README.md”
- Search command or part of it in the history
alias hgrep=”history | grep $1"
iTerm
- Open
.zschrc
quickly
alias openzshrc=”open -a <MY_FAVOURITE_TEXT_EDITOR> ~/.zshrc”
- Load
.zschrc
quickly
alias loadzshrc=”source ~/.zshrc”
React Native
- Start the
packager
alias rns=”adb reverse tcp:8081 tcp:8081 && watchman watch-del-all && react-native start”
- Build and Launch iOS (on iPhone X)
alias rnrios="react-native run-ios --simulator='iPhone X'"
- Build and Launch Android on the currently open emulator
alias rnrandroid="react-native run-android"
NPM | Yarn
- Reset
npm
(deletenode_modules
and reinstall)
alias resetnpm=”rm package-lock.json && rm -rf node_modules && npm i”
- Reset
yarn
(deletenode_modules
and reinstall)
alias resetyarn=”rm yarn.lock && rm -rf node_modules && yarn”
- Switch between private and public
npm
alias npmpublic=”npm config set registry https://registry.npmjs.org/"
alias npmprivate=”npm config set registry http://my-private-npm.com"
- Show remote
dist-tags
alias npmd="npm view $1 dist-tags"
alias yarnd="yarn info $1 dist-tags"
Android
- Android
adb reverse
port 8081
alias rvrs=”adb reverse tcp:8081 tcp:8081"
- Launch big screen Android emulator (for instance, Nexus 5X; the emulator should be preliminary installed)
alias android_big=”cd ~/Library/Android/sdk/tools/; ./emulator -avd Nexus_5X_API_25"
- Launch small screen Android emulator (for instance, Nexus S, the emulator should be preliminary installed)
alias android_small=”cd ~/Library/Android/sdk/tools/; ./emulator -avd Nexus_S_API_25"
- Open Android Studio from root react native app (the root should include
android
folder)
alias as=’open -a /Applications/Android\ Studio.app ./android’
- Reload Android Simulator
alias rr="adb shell am broadcast -a react.native.RELOAD"
Git
- If you use
zsh
you can use all Git commands that are embedded in your terminal — see all commands here - Open repo page in a browser
alias gh=’git config — get remote.origin.url | xargs open’
- Reset
HEAD
(hard)
alias gitresethard=’git add . | echo “all added” | git reset — hard’
- Fetch and rebase
alias gfpr=”git fetch && git pull — rebase”
- Open SourceTree from the current directory (should include
.git/
)
alias stree=”/Applications/SourceTree.app/Contents/Resources/stree .”
Here is the complete list of the aliases. Copy it to your .zshrc
file and remember to adjust to your application installation locations
alias ws="open -a /Applications/WebStorm.app ."
alias scripts="cat package.json | jq -r ‘.scripts’"
alias editReadme="open -a /Applications/MacDown.app README.md"
alias hgrep="history | grep $1"
alias openzshrc="open -a <MY_FAVOURITE_TEXT_EDITOR> ~/.zshrc"
alias loadzshrc="source ~/.zshrc"
alias rns="watchman watch-del-all && react-native start"
alias rnrios="react-native run-ios --simulator='iPhone X'"
alias rnrandroid="react-native run-android"
alias resetnpm="rm package-lock.json && rm -rf node_modules && npm i"
alias resetyarn="rm yarn.lock && rm -rf node_modules && yarn"
alias npmpublic="npm config set registry https://registry.npmjs.org/"
alias npmprivate="npm config set registry http://my-private-npm.com"
alias npmd="npm view $1 dist-tags"
alias yarnd="yarn info $1 dist-tags"
alias rvrs="adb reverse tcp:8081 tcp:8081"
alias android_big="cd ~/Library/Android/sdk/tools/; ./emulator -avd Nexus_5X_API_25"
alias android_small="cd ~/Library/Android/sdk/tools/; ./emulator -avd Nexus_S_API_25"
alias as="open -a /Applications/Android\ Studio.app ./android"
alias rr="adb shell am broadcast -a react.native.RELOAD"
alias gh="git config — get remote.origin.url | xargs open"
alias gitresethard="git add . | echo "resetting hard" | git reset —- hard"
alias gfpr="git fetch && git pull — rebase"
alias tree="/Applications/SourceTree.app/Contents/Resources/stree ."
Does it feel like you can add something to this list?
More then welcome to contact me on twitter @gran33
Like it? please 👏 and share 😍