Alias a shortcut to open a url

The name of the pictureThe name of the pictureThe name of the pictureClash 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.?







share|improve this question
























    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.?







    share|improve this question






















      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.?







      share|improve this question












      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.?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 2 at 4:33









      JawSaw

      29410




      29410




















          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.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            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






























            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.






            share|improve this answer
























              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.






              share|improve this answer






















                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.






                share|improve this answer












                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 2 at 4:54









                Filipe Brandenburger

                3,451621




                3,451621






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    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













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay