0

I can open a URL from command as:

open http://www.google.com

If I tried:

open www.google.com
The file ~/www.google.com does not exist.
Perhaps you meant 'http://www.google.com'?

Nevertheless, it works on Windows like:

start www.google.com

It's not convenient to add 'http://' every time. How to solve the problem?

  • 1
    A URL must begin with a protocol ie the bit before the : so what you have is not a URL. How does the system know to add http it could be mail: ftp: https: etc So the question is where do you get the partial information from and how do you make that app supply the correct information – Mark Mar 10 '18 at 11:11
2

As @Mark said,

A URL must begin with a protocol ie the bit before the : so what you have is not a URL.

You'll need to create your own wrapper for the open command. For example, you can use this function to prepend http:

function openweb() { open http://$1 }

Run with openweb google.com or openweb www.google.com.

Place this in a profile file such as ~/.bash_profile to be available in all interactive shells.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .