Using alias to simplify clone












3















I want to create an alias that looks something like this:



alias getres="git clone https://github.com/user/"


The goal is that i can type "getres repository name" and get the the repository.



However as it stands now,



typing "getres repository name"



Gives me an error saying the repostiory can't be found.










share|improve this question


















  • 1





    Add echo in front of the git clone command so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.

    – Lasse Vågsæther Karlsen
    Nov 24 '18 at 22:28






  • 1





    You want a shell function for this, getres() { git clone https://github.com/user/$*; }

    – jthill
    Nov 24 '18 at 22:38
















3















I want to create an alias that looks something like this:



alias getres="git clone https://github.com/user/"


The goal is that i can type "getres repository name" and get the the repository.



However as it stands now,



typing "getres repository name"



Gives me an error saying the repostiory can't be found.










share|improve this question


















  • 1





    Add echo in front of the git clone command so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.

    – Lasse Vågsæther Karlsen
    Nov 24 '18 at 22:28






  • 1





    You want a shell function for this, getres() { git clone https://github.com/user/$*; }

    – jthill
    Nov 24 '18 at 22:38














3












3








3








I want to create an alias that looks something like this:



alias getres="git clone https://github.com/user/"


The goal is that i can type "getres repository name" and get the the repository.



However as it stands now,



typing "getres repository name"



Gives me an error saying the repostiory can't be found.










share|improve this question














I want to create an alias that looks something like this:



alias getres="git clone https://github.com/user/"


The goal is that i can type "getres repository name" and get the the repository.



However as it stands now,



typing "getres repository name"



Gives me an error saying the repostiory can't be found.







git






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 22:26









mrmaginmrmagin

236




236








  • 1





    Add echo in front of the git clone command so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.

    – Lasse Vågsæther Karlsen
    Nov 24 '18 at 22:28






  • 1





    You want a shell function for this, getres() { git clone https://github.com/user/$*; }

    – jthill
    Nov 24 '18 at 22:38














  • 1





    Add echo in front of the git clone command so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.

    – Lasse Vågsæther Karlsen
    Nov 24 '18 at 22:28






  • 1





    You want a shell function for this, getres() { git clone https://github.com/user/$*; }

    – jthill
    Nov 24 '18 at 22:38








1




1





Add echo in front of the git clone command so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.

– Lasse Vågsæther Karlsen
Nov 24 '18 at 22:28





Add echo in front of the git clone command so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.

– Lasse Vågsæther Karlsen
Nov 24 '18 at 22:28




1




1





You want a shell function for this, getres() { git clone https://github.com/user/$*; }

– jthill
Nov 24 '18 at 22:38





You want a shell function for this, getres() { git clone https://github.com/user/$*; }

– jthill
Nov 24 '18 at 22:38












3 Answers
3






active

oldest

votes


















3














This happens because getres repository name gets translated to:



git clone https://github.com/user/ repository name


which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.



The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.



see Make a Bash alias that takes a parameter?






share|improve this answer





















  • 1





    And you can solve it by using a shell function instead of an alias.

    – Daniel H
    Nov 24 '18 at 22:39






  • 1





    yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment

    – adrhc
    Nov 25 '18 at 1:10





















3














What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }






share|improve this answer































    0














    I have just had this same problem.



    For users using zsh / oh-my-zsh / iterm2 (1,2,3)



    I updated my .zshrc file with the following:



    function getrep(){
    git clone https://github.com/USERNAME/$1.git
    }


    I added the ".git" at the end because I'm lazy.



    Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.



    (1) https://www.zsh.org/



    (2) https://ohmyz.sh/



    (3) https://iterm2.com/






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      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',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462887%2fusing-alias-to-simplify-clone%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      This happens because getres repository name gets translated to:



      git clone https://github.com/user/ repository name


      which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.



      The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.



      see Make a Bash alias that takes a parameter?






      share|improve this answer





















      • 1





        And you can solve it by using a shell function instead of an alias.

        – Daniel H
        Nov 24 '18 at 22:39






      • 1





        yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment

        – adrhc
        Nov 25 '18 at 1:10


















      3














      This happens because getres repository name gets translated to:



      git clone https://github.com/user/ repository name


      which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.



      The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.



      see Make a Bash alias that takes a parameter?






      share|improve this answer





















      • 1





        And you can solve it by using a shell function instead of an alias.

        – Daniel H
        Nov 24 '18 at 22:39






      • 1





        yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment

        – adrhc
        Nov 25 '18 at 1:10
















      3












      3








      3







      This happens because getres repository name gets translated to:



      git clone https://github.com/user/ repository name


      which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.



      The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.



      see Make a Bash alias that takes a parameter?






      share|improve this answer















      This happens because getres repository name gets translated to:



      git clone https://github.com/user/ repository name


      which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.



      The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.



      see Make a Bash alias that takes a parameter?







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Nov 25 '18 at 11:39

























      answered Nov 24 '18 at 22:33









      adrhcadrhc

      470314




      470314








      • 1





        And you can solve it by using a shell function instead of an alias.

        – Daniel H
        Nov 24 '18 at 22:39






      • 1





        yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment

        – adrhc
        Nov 25 '18 at 1:10
















      • 1





        And you can solve it by using a shell function instead of an alias.

        – Daniel H
        Nov 24 '18 at 22:39






      • 1





        yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment

        – adrhc
        Nov 25 '18 at 1:10










      1




      1





      And you can solve it by using a shell function instead of an alias.

      – Daniel H
      Nov 24 '18 at 22:39





      And you can solve it by using a shell function instead of an alias.

      – Daniel H
      Nov 24 '18 at 22:39




      1




      1





      yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment

      – adrhc
      Nov 25 '18 at 1:10







      yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment

      – adrhc
      Nov 25 '18 at 1:10















      3














      What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }






      share|improve this answer




























        3














        What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }






        share|improve this answer


























          3












          3








          3







          What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }






          share|improve this answer













          What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 22:40









          jthilljthill

          27.9k34477




          27.9k34477























              0














              I have just had this same problem.



              For users using zsh / oh-my-zsh / iterm2 (1,2,3)



              I updated my .zshrc file with the following:



              function getrep(){
              git clone https://github.com/USERNAME/$1.git
              }


              I added the ".git" at the end because I'm lazy.



              Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.



              (1) https://www.zsh.org/



              (2) https://ohmyz.sh/



              (3) https://iterm2.com/






              share|improve this answer




























                0














                I have just had this same problem.



                For users using zsh / oh-my-zsh / iterm2 (1,2,3)



                I updated my .zshrc file with the following:



                function getrep(){
                git clone https://github.com/USERNAME/$1.git
                }


                I added the ".git" at the end because I'm lazy.



                Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.



                (1) https://www.zsh.org/



                (2) https://ohmyz.sh/



                (3) https://iterm2.com/






                share|improve this answer


























                  0












                  0








                  0







                  I have just had this same problem.



                  For users using zsh / oh-my-zsh / iterm2 (1,2,3)



                  I updated my .zshrc file with the following:



                  function getrep(){
                  git clone https://github.com/USERNAME/$1.git
                  }


                  I added the ".git" at the end because I'm lazy.



                  Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.



                  (1) https://www.zsh.org/



                  (2) https://ohmyz.sh/



                  (3) https://iterm2.com/






                  share|improve this answer













                  I have just had this same problem.



                  For users using zsh / oh-my-zsh / iterm2 (1,2,3)



                  I updated my .zshrc file with the following:



                  function getrep(){
                  git clone https://github.com/USERNAME/$1.git
                  }


                  I added the ".git" at the end because I'm lazy.



                  Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.



                  (1) https://www.zsh.org/



                  (2) https://ohmyz.sh/



                  (3) https://iterm2.com/







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 12 at 17:05









                  Joshua JonesJoshua Jones

                  22210




                  22210






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462887%2fusing-alias-to-simplify-clone%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Futebolista

                      Lallio

                      Jornalista