How do I set an alias to a terminal line?How do I create a permanent Bash alias?How do I create a permanent Bash alias?Differences between fish and bash to pass commandline arguments to alias functions?How to add an alias to a command in terminal?alias of nodejs as node on 14.04add alias to rootHow can I run original command that aliased with same name?How would I create an alias to run a game? (Minecraft)Bash al (alias local) function not foundWhat is the correct way to create alias to snap package in Ubuntu 16.04?How to set an Alias in bashrc so that System IP can be found using a simple alias command?

Is a single radon-daughter atom in air a solid?

How do I set an alias to a terminal line?

Why don't countries like Japan just print more money?

Why did pressing the joystick button spit out keypresses?

Trainee keeps missing deadlines for independent learning

Really Old Stock Valuation

Parameterize chained calls to a utility program in Bash

Can you find x?

Hot coffee brewing solutions for deep woods camping

Why tighten down in a criss-cross pattern?

Do I have to explain the mechanical superiority of the player-character within the fiction of the game?

What exactly is the 'online' in OLAP and OLTP?

Why use cross notes in sheet music for hip hop tracks?

Can there be an UN resolution to remove a country from the UNSC?

What did River say when she woke from her proto-comatose state?

What does "play with your toy’s toys" mean?

Cut the gold chain

Why does the Saturn V have standalone inter-stage rings?

Is it damaging to turn off a small fridge for two days every week?

Has there been any indication at all that further negotiation between the UK and EU is possible?

"How can you guarantee that you won't change/quit job after just couple of months?" How to respond?

Why do even high-end cameras often still include normal (non-cross-type) AF sensors?

Greeting with "Ho"

Can any NP-Complete Problem be solved using at most polynomial space (but while using exponential time?)



How do I set an alias to a terminal line?


How do I create a permanent Bash alias?How do I create a permanent Bash alias?Differences between fish and bash to pass commandline arguments to alias functions?How to add an alias to a command in terminal?alias of nodejs as node on 14.04add alias to rootHow can I run original command that aliased with same name?How would I create an alias to run a game? (Minecraft)Bash al (alias local) function not foundWhat is the correct way to create alias to snap package in Ubuntu 16.04?How to set an Alias in bashrc so that System IP can be found using a simple alias command?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I want to easily set an alias git-go to this terminal line:



git commit -m "init "; git push; git status


So when I enter git-go this line should enter.



How can I do that? The answers I seen only cover alias of a command without parameters. But I want to set an alias to an arbitrary terminal line.










share|improve this question
























  • What did you try? Which other questions did you read? askubuntu.com/q/17536/507051 explains it quite good, what exactly is your question?

    – dessert
    8 hours ago












  • My issue was using double quotes instead of single for the outside quotes.

    – Philip Rego
    7 hours ago











  • You could as well do it the other way around using double quotes on the outside and single quotes on the inside.

    – Videonauth
    7 hours ago











  • @PhilipRego Even though you've accepted my answer (which shows a correct quoting syntax, as does Videonauth's answer), you may want to post your own answer that focuses specifically on quoting and shows why the way you'd been attempting to quote it didn't work. You're under no obligation to do so, of course. If you do, you may find this section of the Bash reference manual and this page helpful.

    – Eliah Kagan
    7 hours ago

















1















I want to easily set an alias git-go to this terminal line:



git commit -m "init "; git push; git status


So when I enter git-go this line should enter.



How can I do that? The answers I seen only cover alias of a command without parameters. But I want to set an alias to an arbitrary terminal line.










share|improve this question
























  • What did you try? Which other questions did you read? askubuntu.com/q/17536/507051 explains it quite good, what exactly is your question?

    – dessert
    8 hours ago












  • My issue was using double quotes instead of single for the outside quotes.

    – Philip Rego
    7 hours ago











  • You could as well do it the other way around using double quotes on the outside and single quotes on the inside.

    – Videonauth
    7 hours ago











  • @PhilipRego Even though you've accepted my answer (which shows a correct quoting syntax, as does Videonauth's answer), you may want to post your own answer that focuses specifically on quoting and shows why the way you'd been attempting to quote it didn't work. You're under no obligation to do so, of course. If you do, you may find this section of the Bash reference manual and this page helpful.

    – Eliah Kagan
    7 hours ago













1












1








1


0






I want to easily set an alias git-go to this terminal line:



git commit -m "init "; git push; git status


So when I enter git-go this line should enter.



How can I do that? The answers I seen only cover alias of a command without parameters. But I want to set an alias to an arbitrary terminal line.










share|improve this question
















I want to easily set an alias git-go to this terminal line:



git commit -m "init "; git push; git status


So when I enter git-go this line should enter.



How can I do that? The answers I seen only cover alias of a command without parameters. But I want to set an alias to an arbitrary terminal line.







command-line bash alias






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 7 hours ago









Eliah Kagan

84.9k22236377




84.9k22236377










asked 8 hours ago









Philip RegoPhilip Rego

307




307












  • What did you try? Which other questions did you read? askubuntu.com/q/17536/507051 explains it quite good, what exactly is your question?

    – dessert
    8 hours ago












  • My issue was using double quotes instead of single for the outside quotes.

    – Philip Rego
    7 hours ago











  • You could as well do it the other way around using double quotes on the outside and single quotes on the inside.

    – Videonauth
    7 hours ago











  • @PhilipRego Even though you've accepted my answer (which shows a correct quoting syntax, as does Videonauth's answer), you may want to post your own answer that focuses specifically on quoting and shows why the way you'd been attempting to quote it didn't work. You're under no obligation to do so, of course. If you do, you may find this section of the Bash reference manual and this page helpful.

    – Eliah Kagan
    7 hours ago

















  • What did you try? Which other questions did you read? askubuntu.com/q/17536/507051 explains it quite good, what exactly is your question?

    – dessert
    8 hours ago












  • My issue was using double quotes instead of single for the outside quotes.

    – Philip Rego
    7 hours ago











  • You could as well do it the other way around using double quotes on the outside and single quotes on the inside.

    – Videonauth
    7 hours ago











  • @PhilipRego Even though you've accepted my answer (which shows a correct quoting syntax, as does Videonauth's answer), you may want to post your own answer that focuses specifically on quoting and shows why the way you'd been attempting to quote it didn't work. You're under no obligation to do so, of course. If you do, you may find this section of the Bash reference manual and this page helpful.

    – Eliah Kagan
    7 hours ago
















What did you try? Which other questions did you read? askubuntu.com/q/17536/507051 explains it quite good, what exactly is your question?

– dessert
8 hours ago






What did you try? Which other questions did you read? askubuntu.com/q/17536/507051 explains it quite good, what exactly is your question?

– dessert
8 hours ago














My issue was using double quotes instead of single for the outside quotes.

– Philip Rego
7 hours ago





My issue was using double quotes instead of single for the outside quotes.

– Philip Rego
7 hours ago













You could as well do it the other way around using double quotes on the outside and single quotes on the inside.

– Videonauth
7 hours ago





You could as well do it the other way around using double quotes on the outside and single quotes on the inside.

– Videonauth
7 hours ago













@PhilipRego Even though you've accepted my answer (which shows a correct quoting syntax, as does Videonauth's answer), you may want to post your own answer that focuses specifically on quoting and shows why the way you'd been attempting to quote it didn't work. You're under no obligation to do so, of course. If you do, you may find this section of the Bash reference manual and this page helpful.

– Eliah Kagan
7 hours ago





@PhilipRego Even though you've accepted my answer (which shows a correct quoting syntax, as does Videonauth's answer), you may want to post your own answer that focuses specifically on quoting and shows why the way you'd been attempting to quote it didn't work. You're under no obligation to do so, of course. If you do, you may find this section of the Bash reference manual and this page helpful.

– Eliah Kagan
7 hours ago










2 Answers
2






active

oldest

votes


















2














You do this the same way you would set any alias.





alias git-go='git commit -m "init "; git push; git status'


The situation where it gets tricky is not when an alias runs a command and passes arguments to that command, nor even when an alias runs multiple commands separated by ;, but instead is when you want an alias to accept and use its own command-line arguments.



For example, anything you write after the name of that alias will be pasted onto the end, and thus passed as command-line arguments to the third git command, after git status. (Really it's not so much that the following text is pasted onto the end, as much as it is that the following text is left alone and the alias name is replaced with its definition.)



So you can run your alias without arguments, which works, and the last command is git status:



git-go


Or you can run it with arguments that you want passed to git status. For example, when you run it this way, the last command is git-status --show-stash:



git-go --show-stash


What you cannot do with an alias in Bash (and other Bourne-style shells) is to make the alias accept command-line arguments and place them elsewhere than the end.



For example, suppose you wanted git-go to accept an argument that it uses for the commit message. You would not be able to write this as an alias. The solution would be to write it as a shell function instead:



git-go() git commit -m "$1"; git push; git status; 


In the definition of a shell function, the positional parameters $1, $2, and so forth hold the values of the command-line arguments passed to the shell function. Aliases have no functionality that corresponds to this, because alias expansion is really a form of macro processing, taking place very early, when the shell parses a command.



You can, of course, write it as a shell function even if you don't need to use positional parameters in the definition, as Videonauth suggests.






share|improve this answer






























    2














    You can declare it a function in your ~/.bash_aliases file like so:



    git-go()
    git commit -m "init "
    git push
    git status



    or you can create an alias in the same file like so:



    alias git-go='git commit -m "init "; git push; git status'


    Do not forget to reopen your terminal or source the file (. ~/.bash_aliases) after you changed it.






    share|improve this answer

























    • One benefit of writing a shell function instead of an alias is that one needn't nest quotes. This answer thus addresses the central problem the OP turned out to be having more directly than mine does.

      – Eliah Kagan
      7 hours ago












    • @EliahKagan Both are fine for that question although yours is more throughout. Nice to see you back.

      – Videonauth
      7 hours ago













    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    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%2faskubuntu.com%2fquestions%2f1152381%2fhow-do-i-set-an-alias-to-a-terminal-line%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    You do this the same way you would set any alias.





    alias git-go='git commit -m "init "; git push; git status'


    The situation where it gets tricky is not when an alias runs a command and passes arguments to that command, nor even when an alias runs multiple commands separated by ;, but instead is when you want an alias to accept and use its own command-line arguments.



    For example, anything you write after the name of that alias will be pasted onto the end, and thus passed as command-line arguments to the third git command, after git status. (Really it's not so much that the following text is pasted onto the end, as much as it is that the following text is left alone and the alias name is replaced with its definition.)



    So you can run your alias without arguments, which works, and the last command is git status:



    git-go


    Or you can run it with arguments that you want passed to git status. For example, when you run it this way, the last command is git-status --show-stash:



    git-go --show-stash


    What you cannot do with an alias in Bash (and other Bourne-style shells) is to make the alias accept command-line arguments and place them elsewhere than the end.



    For example, suppose you wanted git-go to accept an argument that it uses for the commit message. You would not be able to write this as an alias. The solution would be to write it as a shell function instead:



    git-go() git commit -m "$1"; git push; git status; 


    In the definition of a shell function, the positional parameters $1, $2, and so forth hold the values of the command-line arguments passed to the shell function. Aliases have no functionality that corresponds to this, because alias expansion is really a form of macro processing, taking place very early, when the shell parses a command.



    You can, of course, write it as a shell function even if you don't need to use positional parameters in the definition, as Videonauth suggests.






    share|improve this answer



























      2














      You do this the same way you would set any alias.





      alias git-go='git commit -m "init "; git push; git status'


      The situation where it gets tricky is not when an alias runs a command and passes arguments to that command, nor even when an alias runs multiple commands separated by ;, but instead is when you want an alias to accept and use its own command-line arguments.



      For example, anything you write after the name of that alias will be pasted onto the end, and thus passed as command-line arguments to the third git command, after git status. (Really it's not so much that the following text is pasted onto the end, as much as it is that the following text is left alone and the alias name is replaced with its definition.)



      So you can run your alias without arguments, which works, and the last command is git status:



      git-go


      Or you can run it with arguments that you want passed to git status. For example, when you run it this way, the last command is git-status --show-stash:



      git-go --show-stash


      What you cannot do with an alias in Bash (and other Bourne-style shells) is to make the alias accept command-line arguments and place them elsewhere than the end.



      For example, suppose you wanted git-go to accept an argument that it uses for the commit message. You would not be able to write this as an alias. The solution would be to write it as a shell function instead:



      git-go() git commit -m "$1"; git push; git status; 


      In the definition of a shell function, the positional parameters $1, $2, and so forth hold the values of the command-line arguments passed to the shell function. Aliases have no functionality that corresponds to this, because alias expansion is really a form of macro processing, taking place very early, when the shell parses a command.



      You can, of course, write it as a shell function even if you don't need to use positional parameters in the definition, as Videonauth suggests.






      share|improve this answer

























        2












        2








        2







        You do this the same way you would set any alias.





        alias git-go='git commit -m "init "; git push; git status'


        The situation where it gets tricky is not when an alias runs a command and passes arguments to that command, nor even when an alias runs multiple commands separated by ;, but instead is when you want an alias to accept and use its own command-line arguments.



        For example, anything you write after the name of that alias will be pasted onto the end, and thus passed as command-line arguments to the third git command, after git status. (Really it's not so much that the following text is pasted onto the end, as much as it is that the following text is left alone and the alias name is replaced with its definition.)



        So you can run your alias without arguments, which works, and the last command is git status:



        git-go


        Or you can run it with arguments that you want passed to git status. For example, when you run it this way, the last command is git-status --show-stash:



        git-go --show-stash


        What you cannot do with an alias in Bash (and other Bourne-style shells) is to make the alias accept command-line arguments and place them elsewhere than the end.



        For example, suppose you wanted git-go to accept an argument that it uses for the commit message. You would not be able to write this as an alias. The solution would be to write it as a shell function instead:



        git-go() git commit -m "$1"; git push; git status; 


        In the definition of a shell function, the positional parameters $1, $2, and so forth hold the values of the command-line arguments passed to the shell function. Aliases have no functionality that corresponds to this, because alias expansion is really a form of macro processing, taking place very early, when the shell parses a command.



        You can, of course, write it as a shell function even if you don't need to use positional parameters in the definition, as Videonauth suggests.






        share|improve this answer













        You do this the same way you would set any alias.





        alias git-go='git commit -m "init "; git push; git status'


        The situation where it gets tricky is not when an alias runs a command and passes arguments to that command, nor even when an alias runs multiple commands separated by ;, but instead is when you want an alias to accept and use its own command-line arguments.



        For example, anything you write after the name of that alias will be pasted onto the end, and thus passed as command-line arguments to the third git command, after git status. (Really it's not so much that the following text is pasted onto the end, as much as it is that the following text is left alone and the alias name is replaced with its definition.)



        So you can run your alias without arguments, which works, and the last command is git status:



        git-go


        Or you can run it with arguments that you want passed to git status. For example, when you run it this way, the last command is git-status --show-stash:



        git-go --show-stash


        What you cannot do with an alias in Bash (and other Bourne-style shells) is to make the alias accept command-line arguments and place them elsewhere than the end.



        For example, suppose you wanted git-go to accept an argument that it uses for the commit message. You would not be able to write this as an alias. The solution would be to write it as a shell function instead:



        git-go() git commit -m "$1"; git push; git status; 


        In the definition of a shell function, the positional parameters $1, $2, and so forth hold the values of the command-line arguments passed to the shell function. Aliases have no functionality that corresponds to this, because alias expansion is really a form of macro processing, taking place very early, when the shell parses a command.



        You can, of course, write it as a shell function even if you don't need to use positional parameters in the definition, as Videonauth suggests.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 8 hours ago









        Eliah KaganEliah Kagan

        84.9k22236377




        84.9k22236377























            2














            You can declare it a function in your ~/.bash_aliases file like so:



            git-go()
            git commit -m "init "
            git push
            git status



            or you can create an alias in the same file like so:



            alias git-go='git commit -m "init "; git push; git status'


            Do not forget to reopen your terminal or source the file (. ~/.bash_aliases) after you changed it.






            share|improve this answer

























            • One benefit of writing a shell function instead of an alias is that one needn't nest quotes. This answer thus addresses the central problem the OP turned out to be having more directly than mine does.

              – Eliah Kagan
              7 hours ago












            • @EliahKagan Both are fine for that question although yours is more throughout. Nice to see you back.

              – Videonauth
              7 hours ago















            2














            You can declare it a function in your ~/.bash_aliases file like so:



            git-go()
            git commit -m "init "
            git push
            git status



            or you can create an alias in the same file like so:



            alias git-go='git commit -m "init "; git push; git status'


            Do not forget to reopen your terminal or source the file (. ~/.bash_aliases) after you changed it.






            share|improve this answer

























            • One benefit of writing a shell function instead of an alias is that one needn't nest quotes. This answer thus addresses the central problem the OP turned out to be having more directly than mine does.

              – Eliah Kagan
              7 hours ago












            • @EliahKagan Both are fine for that question although yours is more throughout. Nice to see you back.

              – Videonauth
              7 hours ago













            2












            2








            2







            You can declare it a function in your ~/.bash_aliases file like so:



            git-go()
            git commit -m "init "
            git push
            git status



            or you can create an alias in the same file like so:



            alias git-go='git commit -m "init "; git push; git status'


            Do not forget to reopen your terminal or source the file (. ~/.bash_aliases) after you changed it.






            share|improve this answer















            You can declare it a function in your ~/.bash_aliases file like so:



            git-go()
            git commit -m "init "
            git push
            git status



            or you can create an alias in the same file like so:



            alias git-go='git commit -m "init "; git push; git status'


            Do not forget to reopen your terminal or source the file (. ~/.bash_aliases) after you changed it.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 7 hours ago

























            answered 8 hours ago









            VideonauthVideonauth

            25.9k1281105




            25.9k1281105












            • One benefit of writing a shell function instead of an alias is that one needn't nest quotes. This answer thus addresses the central problem the OP turned out to be having more directly than mine does.

              – Eliah Kagan
              7 hours ago












            • @EliahKagan Both are fine for that question although yours is more throughout. Nice to see you back.

              – Videonauth
              7 hours ago

















            • One benefit of writing a shell function instead of an alias is that one needn't nest quotes. This answer thus addresses the central problem the OP turned out to be having more directly than mine does.

              – Eliah Kagan
              7 hours ago












            • @EliahKagan Both are fine for that question although yours is more throughout. Nice to see you back.

              – Videonauth
              7 hours ago
















            One benefit of writing a shell function instead of an alias is that one needn't nest quotes. This answer thus addresses the central problem the OP turned out to be having more directly than mine does.

            – Eliah Kagan
            7 hours ago






            One benefit of writing a shell function instead of an alias is that one needn't nest quotes. This answer thus addresses the central problem the OP turned out to be having more directly than mine does.

            – Eliah Kagan
            7 hours ago














            @EliahKagan Both are fine for that question although yours is more throughout. Nice to see you back.

            – Videonauth
            7 hours ago





            @EliahKagan Both are fine for that question although yours is more throughout. Nice to see you back.

            – Videonauth
            7 hours ago

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Ask Ubuntu!


            • 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%2faskubuntu.com%2fquestions%2f1152381%2fhow-do-i-set-an-alias-to-a-terminal-line%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

            ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

            Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу