How to set React_Editor to PhpStorm so that when you click on the error it jumps to the code? - react-native

I'm using PhpStorm in Mac to code and i want to debug my errors. I have a message in my terminal to set the editor for React Native tools.
PRO TIP
When you see Red Box with stack trace, you can click any
stack frame to jump to the source file. The packager will launch your
editor of choice. It will first look at REACT_EDITOR environment
variable, then at EDITOR.
To set it up, you can add something like
export REACT_EDITOR=atom to your ~/.bashrc or ~/.zshrc depending on
which shell you use.
I've added these lines to ~/.bashrc but nothing happened when i click on the error :
export PATH=$PATH:/usr/local/bin/pstorm
export REACT_EDITOR=pstorm
How can i set correctly REACT_EDITOR to PhpStorm so that when i click on the error it jumps to my code?

For mac os you need to add to ~/.bashrc or .zprofile:
Add export REACT_EDITOR="webstorm" or pstorm
Don't forget to close all of your terminal windows and restart the react-native packager before you try it.
Create a shortcut to open WebStorm:
Open WebStorm
Press ⇧ twice to open the search window
Type “Create Command Line Launcher…” and press Enter
Click OK
That's it.
/usr/local/bin should be in the PATH environment variable by default. You should be able to run webstorm from anywhere in the shell. Run webstorm /usr/local/bin/webstorm to test the command.
You can find a code which opens editors here or in your project node_modules/#react-native-community/cli-tools/build/launchEditor.js

I solved this problem by creating symlink.
sudo ln -s /Applications/WebStorm.app/Contents/MacOS/webstorm /usr/local/bin/webstorm

Related

Reload a React Native app on an Android device manually via command line

I'd like to manually force a Reload of my React Native app on demand without physically shaking the device. (I'm getting carpal tunnel.)
I know that Live Reload / Hot Reload are available. I'm looking for a on-demand command line solution.
Using the cmd line you can send a command to the Android device.
adb shell input text "RR"
This command tells the Android device to type the character "R" twice which is the React Native command to Reload on Android.
The adb shell command has many useful features many of which are described here:
ADB Shell Input Events
To open the developer menu:
adb shell input keyevent 82
Just posting it here in case you didn't know this trick
long press the menu button in your android device. Then you'll get this menu
tap the reload option and you are good to go
I use the following command. It doesn't reload the app, but it brings up the developper menu on the device, so I can then press the "Reload" option:
adb shell input keyevent KEYCODE_MENU
I develop with a real device (not the emulator) and sending the "double-R" through adb doesn't work (it just shows the keyboard and types 2 Rs).
Add the following script to your package.json:
"android-shake": "adb shell input keyevent 82"
Then you will be able to call
yarn android-shake
If you are looking for ios then checkout my answer on this link
One trick would be to add this command on ~/.bashrc profile in the case you're using unix.
use your favorite editor (ex: nano on Ubuntu) and type nano ~/.bashrc
on the end of file write alias rnreload='adb shell input text "RR"'
save it and run source ~/.bashrc in order to active it.
Now whenever you need, just type rnreload on a terminal.
Next time you enter your computer it should be already done.
Also, there's the possibility to add an other alias as well: alias rnshake='adb shell input keyevent 82' which "shakes" android. You can use it to access other commands like Hot Reloading, Debugger, Inspector, etc.
Made an autohotkey script to reload and open the menu with keyboard shortcuts.
^+r:: run, %comspec% /c adb shell input text "RR",,hide
^+e:: run, %comspec% /c adb shell input keyevent 82,,hide
ctrl+shift+r to reload
ctrl+shift+e to open dev menu
If you're on a Mac and using Hammerspoon, you can put the following bit of code in your ~/.hammerspoon/init.lua file:
hyper = {'ctrl', 'alt', 'cmd'}
placid = {'ctrl', 'cmd'}
-- React native reload JS on connected device
hs.hotkey.bind(placid, 'R', function()
os.execute('/Users/peter/Library/Android/sdk/platform-tools/adb shell input text "RR"')
end)
-- React native show dev menu on connected device
hs.hotkey.bind(hyper, 'R', function()
os.execute('/Users/peter/Library/Android/sdk/platform-tools/adb shell input keyevent 82')
end)
the os.execute command doesn't load your ENV (doing so would make running commands really slow), so make sure to run which adb in your terminal to figure out what the exact path to adb is. (in my case it was /Users/peter/Library/Android/sdk/platform-tools/adb).
Now you can reload your app using ctrl+cmd+R and show the dev menu using ctrl+option+cmd+R from anywhere and without even bothering to cmd-tab out of your favorite editor!
For device you have just to shake your device than a menu appears so click on Reload

How to edit React Native tools?

PRO TIP
When you see Red Box with stack trace, you can click any
stack frame to jump to the source file. The packager will launch your
editor of choice. It will first look at REACT_EDITOR environment
variable, then at EDITOR. To set it up, you can add something like
REACT_EDITOR=atom to your .bashrc.
.bashrc:
export GOROOT=/usr/local/go
export REACT_EDITOR=atom
For Visual Studio Code
Add code below to ~/.zshrc or ~/.bashrc file
export PATH=$PATH:/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin
export REACT_EDITOR=code
When you see Red Box with stack trace, you can click any stack frame to jump to the source file. The packager will launch your editor of choice. It will first look at REACT_EDITOR environment variable, then at EDITOR.
To set it up, you can add something like REACT_EDITOR=atom to your .bashrc.
# .bashrc
export GOROOT=/usr/local/go
export REACT_EDITOR=atom
To set it up, you can add something like REACT_EDITOR=atom to your .bashrc or .profile.
#.profile
export NVM_DIR="/usr/local/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
export REACT_EDITOR="atom" # Add atom to REACT_EDITOR for scripting
If you do make any edits to this file once you have closed it, you need to run the command in your command line:
source ~/.profile
to compile your newly applied edits. If you see any errors after sourcing your file get them fixed before moving to the final step.
For my example,it works in .profile,but doesn't work in .bashrc. I guess it is related with NVM_DIR path.I hope it can help you:)

Editing profiles in arch linux

I am very new to Arch Linux and have chrooted into the system. I screwed up the wireless profile, but have fixed them in netctl. How do I write to the file and exit out of the text editor that is prompted for you to edit the file?
To write to the file:
sudo nano /path/to/file
And to exit from the nano text editor press Control X.
Then Y to confirm save and exit, and enter to commit the save.
It depends on what type of editor has been opened. Which you can set in the .bashrc file.
If it is nano press ctrl+o to save the changes and ctrl+x to quit
If it is vi or vim, Goto command mode by pressing escape. Then type :wq to write and press enter.
If you are not able to make out between the two, just check if it has shortcut key info at the bottom of the page, if yes. It is nano or else it is vi.
PS: Since you are new the arch linux I assumed that you have not installed any other CLI based editors.

"Git Bash here" isn't working when right clicking

I don't know, how that happened but before today I could right click on any folder and there would be and an option Git Bash here. But today I dont have that option. Anyone knows how to get that back?
HOW TO FIX WITHOUT RE-Installing:
I got this problem after moving all my programs off of my main hard drive and pasting them into my "P" drive. But kept all of the directory structures the same.
Git was moved from:
C:\DEV\PROG\GIT
TO:
P:\DEV\PROG\GIT
1: Open The Registry Editor:
Type "regedit" in start menu search and hit enter.
2: Find the context menu shortcut configuration for "git bash here"
In regedit: Menu "Edit" > "Find" > "Find what" and enter "git_shell"
3: Edit the Data value so that path points to the correct location.
In my case I changed:
"C:\DEV\PROG\GIT\git-bash.exe" "--cd=%v."
TO:
"P:\DEV\PROG\GIT\git-bash.exe" "--cd=%v."
Screen shot included below.
Steps if you can't use the reinstall metod.
Use REGEDIT
1/ Open regedit (search it if needed)
2/ Go to 'HKEY_CURRENT_USER/Software/Classes/Directory/Background'
3/ Create new key 'shell'
4/ Create new key 'Git bash here' (or whatever name you want to see in the menu)
5/ Create new key 'command' (must be named command)
At this point point you'll have
'HKEY_CURRENT_USER/Software/Directory/Background/shell/Git bash here/command'
6/ Edit the value of the command key as follow 'pathToGit/git-bash.exe'
Update or open new windows explorer and you'll see it when right clicking.
Image to sum this up :
Reinstall Git and select:
Context menu entries: "Git Bash Here" (and the "Git GUI Here" option)
During the installation. Can't say why it disappeared, but this should bring it back.
Run this script (AddGitToExplorerContextMenu.reg).
You may need to update the location of Git. You can add it
manually through regedit also
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell]
#="Git Bash"
[HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell\command]
#="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%v.\""
Had the same issue , realized that previously right clicking anywhere or inside the folder the Option would show but now I had to select or highlight the folder and then right_click for the option to show.
Uninstall Git completely and delete the Git folder in program files.
Install Git.
From the Context menu, select "Git Bash" & "Git GUI here" options.
I found what I was looking for was in the left pane, not in the right folder. And still using the right-click.
Press SHIFT+F10. It will appear
After Windows 11 update, it got invisible. I first uninstalled the older version and installed the latest 2.35 version. it was still not visible.
It is still there albeit inside another folder in the context menu that comes with a right click.
By going inside any folder right-click INSIDE that folder, in German OS there is
Shift + F10 combination you have it there like before. Or without this shortcut combination go inside Further option (This last) it is there.
It worked fine when I was using Win 10 ,after upgrading my windows to 11 it stopped working.
I solved my problem by following these simple steps.
Uninstall Git completely on computer
Download it here : https://git-scm.com/download/win
Install it
It works fine now!!!
Once you right click on the folder , click on 'Show More Options'.
Now you should be able to see all the earlier options such as 'Git Bash Here'

How do I install uncrustify?

How do I install uncrustify? I followed the instruction to install uncrustify but when I run it, it does not work. Can anyone give me some help installing this tool? I want to run it on objective-c code in xcode 4. Thanks in adavance
On OS X Mavericks 10.9.1 :
1- to install brew, open a terminal windows and type :
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
It will ask you to download some other files, answer OK for all (for more information see : http://brew.sh/index_fr.html).
2 - to install uncrusify, open a terminal windows an type :
brew install uncrustify
3 - to make your code beautiful, download BBUncrustifyPlugin-Xcode available at https://github.com/benoitsan/BBUncrustifyPlugin-Xcode
You will just have to :
compile the project
copy the file uncrusify.cfg in your home directory
restart Xcode.
NB : With BBUncrustifyPlugin, you don't need to use Automator.
4 - After restarting Xcode, use the menu Edit > Uncrustify Selected Files to uncrustify the selected items in the project navigator.
Your code is now beautiful! That's magic!
post-scriptum : You can easily change your uncrusify configuration file by using :
https://github.com/ryanmaxwell/UncrustifyX
http://universalindent.sourceforge.net (better in my case)
I hope that this will help!
I setup Uncrustify with Xcode 4 like so: http://blog.carbonfive.com/2011/03/10/code-formatting-in-xcode-4/
Can you explain what you tried to do, what you expected to happen, and how it didn't work?
Download zip
On Windows, download the latest version of Uncrustify here: https://sourceforge.net/projects/uncrustify/files/latest/download
Extract zip
The program is a standalone exe, so just extract the downloaded uncrustify-...-win32.zip file anywhere. For this example, I'll use C:\Uncrustify. So, the uncrustify.exe would be in that directory.
Add directory to PATH System Environment Variable
In Windows 7+: Type Winkey + env - Select "Edit the system environment variables"
On the Advanced tab, click the Environment Variables button at the bottom.
In the System variables section at the bottom, click the Path variable, then click the Edit... button.
Click the New button, and type C:\Uncrustify, or the directory that you extracted uncrustify.exe to.
Important: Click OK to close the dialog boxes or your change will not save.
Verify
In a CMD window, typing where uncrustify should return the path to the uncrustify.exe.
In my case it shows C:\Uncrustify\uncrustify.exe
Close Atom and reopen it. Now you should be able to atom-beautify and it will use Uncrustify to format your selection