[git] How to open google chrome from terminal?

I'm trying to create an alias that opens google chrome to localhost. Port 80 in this case.

I'd also really like to be able to be in any git directory and have it open that specific project in the browser, but I'm not sure if that's even possible.

  • How do I open google chrome from the terminal?
  • What alias could I use to open the current git project in the browser?

More Details:

  1. My localhost is set to port 80.
  2. I store my git repositories in ~/Sites/ - meaning if I wanted to view any project in the browser it would be found here: http://localhost/FILENAME

Thank You

This question is related to git bash google-chrome terminal alias

The answer is


I'm not sure how extensively you've searched, but this seems to be similar to what you're searching for:

https://apple.stackexchange.com/questions/83630/create-a-terminal-command-to-open-file-with-chrome

(I just assumed you're using Mac since you used the word "terminal")


From the macOS Terminal, use open with the -a flag and give the name of the app you want to open. In this case "Google Chrome". You may pass it a file or URL you want it to open with.

open -a "Google Chrome" index.html 

In Terminal, type open -a Google\ Chrome

This will open Google Chrome application without any need to manipulate directories!


on mac terminal (at least in ZSH): open stackoverflow.com (opens site in new tab in your chrome default browser)


On Linux, just use this command in a terminal:

google-chrome

just type

google-chrome

it works. Thanks.


Use command

google-chrome-stable

We can also use command

google-chrome

To open terminal but in my case when I make an interrupt ctrl + c then it get closed so I would recommend to use google-chrome-stable instead of google-chrome


If you just want to open the Google Chrome from terminal instantly for once then open -a "Google Chrome" works fine from Mac Terminal.

If you want to use an alias to call Chrome from terminal then you need to edit the bash profile and add an alias on ~/.bash_profile or ~/.zshrc file.The steps are below :

  • Edit ~/.bash_profile or ~/.zshrc file and add the following line alias chrome="open -a 'Google Chrome'"
  • Save and close the file.
  • Logout and relaunch Terminal
  • Type chrome filename for opening a local file.
  • Type chrome url for opening url.

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to bash

Comparing a variable with a string python not working when redirecting from bash script Zipping a file in bash fails How do I prevent Conda from activating the base environment by default? Get first line of a shell command's output Fixing a systemd service 203/EXEC failure (no such file or directory) /bin/sh: apt-get: not found VSCode Change Default Terminal Run bash command on jenkins pipeline How to check if the docker engine and a docker container are running? How to switch Python versions in Terminal?

Examples related to google-chrome

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 SameSite warning Chrome 77 What's the net::ERR_HTTP2_PROTOCOL_ERROR about? session not created: This version of ChromeDriver only supports Chrome version 74 error with ChromeDriver Chrome using Selenium Jupyter Notebook not saving: '_xsrf' argument missing from post How to fix 'Unchecked runtime.lastError: The message port closed before a response was received' chrome issue? Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser How to make audio autoplay on chrome How to handle "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first." on Desktop with Chrome 66?

Examples related to terminal

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave Flutter command not found VSCode Change Default Terminal How to switch Python versions in Terminal? How to open the terminal in Atom? Color theme for VS Code integrated terminal How to edit a text file in my terminal How to open google chrome from terminal? Switch between python 2.7 and python 3.5 on Mac OS X

Examples related to alias

How to open google chrome from terminal? Aliases in Windows command prompt SQL alias for SELECT statement How do I run a shell script without using "sh" or "bash" commands? Is the 'as' keyword required in Oracle to define an alias? Make a Bash alias that takes a parameter? List Git aliases How to write UPDATE SQL with Table alias in SQL Server 2008? Should I use alias or alias_method? SQL - using alias in Group By