Skip to content

Open Metro in iTerm on macOS #303

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
cpojer opened this issue Apr 9, 2019 · 9 comments · Fixed by #310
Closed

Open Metro in iTerm on macOS #303

cpojer opened this issue Apr 9, 2019 · 9 comments · Fixed by #310

Comments

@cpojer
Copy link
Member

cpojer commented Apr 9, 2019

Describe the Feature

A lot of people use iTerm 2 on macOS. When using run-android or run-ios, Metro is started in Terminal.app even when launched from iterm. Ideally we'd create a new tab or window in iTerm.

Possible Implementations

  • If there is a way to detect whether run-android/ios was invoked from within iTerm, use iTerm.
  • Otherwise, provide a way to set this as a configuration (per project, per computer) once and reuse the setting

Related Issues

Note that run-android already has an option to chose the terminal via an environment variable. It looks like it should work but it didn't when I just tested it.

@thymikee
Copy link
Member

thymikee commented Apr 9, 2019

Current terminal is available behind TERM_PROGRAM (at least on macOS), so we should likely try that before the REACT_TERMINAL and a default one.

facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Apr 15, 2019
Summary:
This PR specifies the correct terminal to start the Metro bundler as stated in react-native-community/cli#303.

[iOS] [Changed] - Start the packager on the correct terminal.
Pull Request resolved: #24436

Differential Revision: D14932703

Pulled By: cpojer

fbshipit-source-id: 4c9b5a380ff4f4767acbeb6872e11e03df5b160c
@talon-himself
Copy link

You can always open Finder and find the launchPackager.command file under node_modules/react-native/scripts/. Right click the file, choose get info, then change the "Open with:" section to iTerm, and click on Change All.

@gatspy
Copy link

gatspy commented Dec 20, 2019

npx react-native run-ios also open Terminal.app

@swrobel
Copy link

swrobel commented Dec 11, 2020

anyone ... maybe @lucasbento ... clear on why both of these still open Terminal.app, not iTerm?

$ yarn react-native run-ios --terminal iTerm

$ REACT_TERMINAL=iTerm yarn react-native run-ios

I've also tried iTerm.app instead of iTerm and the behavior is the same

macOS 10.17.7
react-native-community/cli: 4.13.1
react-native: 0.63.4

@mattwoberts
Copy link

@swrobel I think the --terminal attribute only applies to the build of the project. Metro always loads in teminal.app for me, no matter what you try changing this to. I resolved this with the handy hint from @TheTalonHughes above.

@swrobel
Copy link

swrobel commented Dec 14, 2020

Thanks @mattwoberts but the examples provided in #310 indicate that it should work with run-ios...

@good-idea
Copy link

I'm using tmux and the trick above doesn't work... It would be nice if the process just ran in the same shell where I invoke run-ios!!

@willxy
Copy link

willxy commented Dec 30, 2022

Looks like this was implemented in facebook/react-native#24436 which added support for $RCT_TERMINAL, $REACT_TERMINAL, and $TERM_PROGRAM in React/React.xcodeproj/project.pbxproj, but looks like React/React.xcodeproj/project.pbxproj was later removed in facebook/react-native#25583.

There's now a https://github.com/facebook/react-native/blob/main/template/ios/HelloWorld.xcodeproj/project.pbxproj but that doesn't include any of the support for $RCT_TERMINAL, $REACT_TERMINAL, $TERM_PROGRAM etc.

@dev-danilo
Copy link

anyone ... maybe @lucasbento ... clear on why both of these still open Terminal.app, not iTerm?

$ yarn react-native run-ios --terminal iTerm

$ REACT_TERMINAL=iTerm yarn react-native run-ios

I've also tried iTerm.app instead of iTerm and the behavior is the same

macOS 10.17.7 react-native-community/cli: 4.13.1 react-native: 0.63.4

Worked here
Thank you! 🚀

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants