Reputation: 1939
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.
More Details:
http://localhost/FILENAME
Thank You
Upvotes: 116
Views: 256856
Reputation: 5698
For macOS you can use this command:
open -a Google\ Chrome "https://google.com"
Upvotes: 11
Reputation: 181
On linux [ubuntu] in terminal, write:
google-chrome 'https://google.com' 2> /dev/null
ending part 2> /dev/null
ommits output from command in terminal and allows to type without disturbing comments from that command.
for new-ones in scripting (linux users):
u can also create some nice readable function in ~/.bashrc
directory like:
open(){
google-chrome $1 2> /dev/null
}
and in terminal using it like this:
open htts://google.com
Upvotes: 2
Reputation: 41
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
Upvotes: 4
Reputation: 41
on mac terminal (at least in ZSH): open stackoverflow.com
(opens site in new tab in your chrome default browser)
Upvotes: 4
Reputation: 845
In Terminal, type open -a Google\ Chrome
This will open Google Chrome application without any need to manipulate directories!
Upvotes: 2
Reputation: 1939
UPDATE:
Thank you for the quick response. open http://localhost/
opened that domain in my default browser on my Mac.
I ended up writing this alias, did the trick:
# Opens git file's localhost; ${PWD##*/} is the current directory's name
alias lcl='open "http://localhost/${PWD##*/}/"'
Thank you again!
Upvotes: 15
Reputation: 1963
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
Upvotes: 154
Reputation: 704
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 :
~/.bash_profile
or ~/.zshrc
file and add the following line alias chrome="open -a 'Google Chrome'"
chrome filename
for opening a local file.chrome url
for opening url.Upvotes: 32