I set an alias:
$ alias net="open https://www."
Try it:
$ net google.com
The file /Users/me/google.com does not exist.
How enable the alias going to open any url without the prefix open https://www.
?
You can't use an alias to do that exactly, since an alias expands to the whole words of its expansion, so the net result of net google.com
is open https://www. google.com
(which explains why it's trying to find a file named google.com
.)
Instead of an alias, use a function, which essentially works in the same context as an alias, but it's more generic and allows for better handling of arguments.
Something like this would work:
(In case you still have the alias set, start by removing it:)
$ unalias net
Then define a function to open the URL:
$ net() { open "https://www.$1"; }
And then try it with:
$ net google.com
See also this answer about when to use aliases, functions or scripts in bash, which you might find interesting.