Custom terminal command for reloading React Native app in android

Subash Poudel
2 min readJun 10, 2018

--

React Native is a cool technology and one of its most used feature during development is reloading. Unfortunately, if you use a physical device, you need to shake your device to open the dev menu.

To tackle this issue, at first, I tried the solution presented by Jesse Sessler in this blog:

If you didn’t read his article, then here’s the TLDR:

Execute command adb shell input keyevent KEYCODE_MENU, using Automator app by registering a system wide keyboard shortcut.

I was able to get it to work but it was not very reliable. System wide shortcut that I registered would work when chrome was the currently used app but fail when I used it in iTerm.

So, I decided to create a new terminal command rnr to achieve the same result. Note, I am using a mac with zsh and iTerm. Linux should be similar and windows god bless you.

Instructions:

1. cd ~ // go to the home folder2. touch .rnr.sh // create a shell script file3. nano .rnr.sh // opens .rnr.sh file in terminal for editing4. Paste the following code:# opens dev options menu in react native app for android
function rnr() {
adb shell input keyevent KEYCODE_MENU
}
5. Save file (control + x, y, enter)6. open ~/.zshrc // you might have a .bashrc file7. Append source ~/.rnr.sh to the last line of the file8. Save9. Restart the terminal10. rnr // commands opens the dev menu

It’s not ideal but is better than shaking your phone.

--

--

Subash Poudel

Software Engineer at Leapfrog. Swift enthusiast. I like reading blogs and watching NBA games in my free time.