Alias a shortcut to open a url
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
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.
?
bash
add a comment |Â
up vote
0
down vote
favorite
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.
?
bash
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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.
?
bash
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.
?
bash
asked Apr 2 at 4:33
JawSaw
29410
29410
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
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.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
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.
add a comment |Â
up vote
2
down vote
accepted
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.
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
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.
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.
answered Apr 2 at 4:54
Filipe Brandenburger
3,451621
3,451621
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f434966%2falias-a-shortcut-to-open-a-url%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password