Is there any way to create bash like aliases in windows (powershell or cmd)?












1















I want to create an alias that can still take input, like:



alias ytx='youtube-dl -ciw -f bestaudio --yes-playlist


Is this possible within windows?



I tried bash aliases equivalent for powershell? but it doesn't allow for input at the end.










share|improve this question



























    1















    I want to create an alias that can still take input, like:



    alias ytx='youtube-dl -ciw -f bestaudio --yes-playlist


    Is this possible within windows?



    I tried bash aliases equivalent for powershell? but it doesn't allow for input at the end.










    share|improve this question

























      1












      1








      1








      I want to create an alias that can still take input, like:



      alias ytx='youtube-dl -ciw -f bestaudio --yes-playlist


      Is this possible within windows?



      I tried bash aliases equivalent for powershell? but it doesn't allow for input at the end.










      share|improve this question














      I want to create an alias that can still take input, like:



      alias ytx='youtube-dl -ciw -f bestaudio --yes-playlist


      Is this possible within windows?



      I tried bash aliases equivalent for powershell? but it doesn't allow for input at the end.







      windows-10 powershell cmd.exe






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 1 at 19:46









      Timen ZandbergenTimen Zandbergen

      82




      82






















          2 Answers
          2






          active

          oldest

          votes


















          0














          The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH.



          For passing input to batch files, use %*, which evaluates to "all parameters passed to the batch file command line", or, use %1, %2, ... %9 to refer to individual parameters.



          Personally, I keep my batch files in C:Batch and place it in the begining of my PATH. When running the batch files, you could omit the .bat suffix, to get a similar look-and-feel to bash aliases.



          Few examples of my own:





          • s3cmd.bat, which contains: python c:devtoolss3cmd-2.0.0s3cmd %*.
            All parameters are passed directly to the actual s3cmd program.


          • clangcheck.bat, which is a shorthand for:
            clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*. Here, the batch parameters are passed along with extra arguments to clang-check.


          • epoch_to_time.bat, which converts Unix epoch time to readable local time.

            It contains: perl -pe "s/([d]{10})/localtime $1/eg;" %1. Here, %1 is the epoch time to convert, which is expected as a single parameter.






          share|improve this answer

































            0














            The equivalent command is the
            doskey command, which you may use as:



            doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*


            where $* represents all the parameters.



            Here is a small example that echos its parameters:



            enter image description here



            Doskey can also be used in PowerShell. For more information see
            this answer.



            For making a doskey macro persistent across sessions, see the post
            Create permanent DOSKEY in Windows cmd.






            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "3"
              };
              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%2fsuperuser.com%2fquestions%2f1389589%2fis-there-any-way-to-create-bash-like-aliases-in-windows-powershell-or-cmd%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









              0














              The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH.



              For passing input to batch files, use %*, which evaluates to "all parameters passed to the batch file command line", or, use %1, %2, ... %9 to refer to individual parameters.



              Personally, I keep my batch files in C:Batch and place it in the begining of my PATH. When running the batch files, you could omit the .bat suffix, to get a similar look-and-feel to bash aliases.



              Few examples of my own:





              • s3cmd.bat, which contains: python c:devtoolss3cmd-2.0.0s3cmd %*.
                All parameters are passed directly to the actual s3cmd program.


              • clangcheck.bat, which is a shorthand for:
                clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*. Here, the batch parameters are passed along with extra arguments to clang-check.


              • epoch_to_time.bat, which converts Unix epoch time to readable local time.

                It contains: perl -pe "s/([d]{10})/localtime $1/eg;" %1. Here, %1 is the epoch time to convert, which is expected as a single parameter.






              share|improve this answer






























                0














                The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH.



                For passing input to batch files, use %*, which evaluates to "all parameters passed to the batch file command line", or, use %1, %2, ... %9 to refer to individual parameters.



                Personally, I keep my batch files in C:Batch and place it in the begining of my PATH. When running the batch files, you could omit the .bat suffix, to get a similar look-and-feel to bash aliases.



                Few examples of my own:





                • s3cmd.bat, which contains: python c:devtoolss3cmd-2.0.0s3cmd %*.
                  All parameters are passed directly to the actual s3cmd program.


                • clangcheck.bat, which is a shorthand for:
                  clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*. Here, the batch parameters are passed along with extra arguments to clang-check.


                • epoch_to_time.bat, which converts Unix epoch time to readable local time.

                  It contains: perl -pe "s/([d]{10})/localtime $1/eg;" %1. Here, %1 is the epoch time to convert, which is expected as a single parameter.






                share|improve this answer




























                  0












                  0








                  0







                  The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH.



                  For passing input to batch files, use %*, which evaluates to "all parameters passed to the batch file command line", or, use %1, %2, ... %9 to refer to individual parameters.



                  Personally, I keep my batch files in C:Batch and place it in the begining of my PATH. When running the batch files, you could omit the .bat suffix, to get a similar look-and-feel to bash aliases.



                  Few examples of my own:





                  • s3cmd.bat, which contains: python c:devtoolss3cmd-2.0.0s3cmd %*.
                    All parameters are passed directly to the actual s3cmd program.


                  • clangcheck.bat, which is a shorthand for:
                    clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*. Here, the batch parameters are passed along with extra arguments to clang-check.


                  • epoch_to_time.bat, which converts Unix epoch time to readable local time.

                    It contains: perl -pe "s/([d]{10})/localtime $1/eg;" %1. Here, %1 is the epoch time to convert, which is expected as a single parameter.






                  share|improve this answer















                  The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH.



                  For passing input to batch files, use %*, which evaluates to "all parameters passed to the batch file command line", or, use %1, %2, ... %9 to refer to individual parameters.



                  Personally, I keep my batch files in C:Batch and place it in the begining of my PATH. When running the batch files, you could omit the .bat suffix, to get a similar look-and-feel to bash aliases.



                  Few examples of my own:





                  • s3cmd.bat, which contains: python c:devtoolss3cmd-2.0.0s3cmd %*.
                    All parameters are passed directly to the actual s3cmd program.


                  • clangcheck.bat, which is a shorthand for:
                    clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*. Here, the batch parameters are passed along with extra arguments to clang-check.


                  • epoch_to_time.bat, which converts Unix epoch time to readable local time.

                    It contains: perl -pe "s/([d]{10})/localtime $1/eg;" %1. Here, %1 is the epoch time to convert, which is expected as a single parameter.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 1 at 20:12

























                  answered Jan 1 at 20:01









                  valianovaliano

                  229110




                  229110

























                      0














                      The equivalent command is the
                      doskey command, which you may use as:



                      doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*


                      where $* represents all the parameters.



                      Here is a small example that echos its parameters:



                      enter image description here



                      Doskey can also be used in PowerShell. For more information see
                      this answer.



                      For making a doskey macro persistent across sessions, see the post
                      Create permanent DOSKEY in Windows cmd.






                      share|improve this answer




























                        0














                        The equivalent command is the
                        doskey command, which you may use as:



                        doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*


                        where $* represents all the parameters.



                        Here is a small example that echos its parameters:



                        enter image description here



                        Doskey can also be used in PowerShell. For more information see
                        this answer.



                        For making a doskey macro persistent across sessions, see the post
                        Create permanent DOSKEY in Windows cmd.






                        share|improve this answer


























                          0












                          0








                          0







                          The equivalent command is the
                          doskey command, which you may use as:



                          doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*


                          where $* represents all the parameters.



                          Here is a small example that echos its parameters:



                          enter image description here



                          Doskey can also be used in PowerShell. For more information see
                          this answer.



                          For making a doskey macro persistent across sessions, see the post
                          Create permanent DOSKEY in Windows cmd.






                          share|improve this answer













                          The equivalent command is the
                          doskey command, which you may use as:



                          doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*


                          where $* represents all the parameters.



                          Here is a small example that echos its parameters:



                          enter image description here



                          Doskey can also be used in PowerShell. For more information see
                          this answer.



                          For making a doskey macro persistent across sessions, see the post
                          Create permanent DOSKEY in Windows cmd.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 1 at 20:24









                          harrymcharrymc

                          257k14269571




                          257k14269571






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Super User!


                              • 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%2fsuperuser.com%2fquestions%2f1389589%2fis-there-any-way-to-create-bash-like-aliases-in-windows-powershell-or-cmd%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

                              Список кардиналов, возведённых папой римским Каликстом III

                              Deduzione

                              Mysql.sock missing - “Can't connect to local MySQL server through socket”