Create multiple shell aliases at once

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
8
down vote

favorite
1












I want to insert into alias different possible variants of spelling, for example, cat command. Can I do it using some symbol for 'or' or should it be on a new line?



alias at|cart|cst '/bin/cat'






share|improve this question


















  • 7




    Reminds me of one alias I have: alias kk='ll'
    – RoVo
    May 16 at 7:42






  • 14




    I wouldn't recommend using at as an alias for cat. There's an actual command at for scheduling stuff: askubuntu.com/a/339301/295286
    – Sergiy Kolodyazhnyy
    May 16 at 8:02














up vote
8
down vote

favorite
1












I want to insert into alias different possible variants of spelling, for example, cat command. Can I do it using some symbol for 'or' or should it be on a new line?



alias at|cart|cst '/bin/cat'






share|improve this question


















  • 7




    Reminds me of one alias I have: alias kk='ll'
    – RoVo
    May 16 at 7:42






  • 14




    I wouldn't recommend using at as an alias for cat. There's an actual command at for scheduling stuff: askubuntu.com/a/339301/295286
    – Sergiy Kolodyazhnyy
    May 16 at 8:02












up vote
8
down vote

favorite
1









up vote
8
down vote

favorite
1






1





I want to insert into alias different possible variants of spelling, for example, cat command. Can I do it using some symbol for 'or' or should it be on a new line?



alias at|cart|cst '/bin/cat'






share|improve this question














I want to insert into alias different possible variants of spelling, for example, cat command. Can I do it using some symbol for 'or' or should it be on a new line?



alias at|cart|cst '/bin/cat'








share|improve this question













share|improve this question




share|improve this question








edited May 16 at 7:57









Melebius

3,65041636




3,65041636










asked May 16 at 7:32









Josef Klimuk

542112




542112







  • 7




    Reminds me of one alias I have: alias kk='ll'
    – RoVo
    May 16 at 7:42






  • 14




    I wouldn't recommend using at as an alias for cat. There's an actual command at for scheduling stuff: askubuntu.com/a/339301/295286
    – Sergiy Kolodyazhnyy
    May 16 at 8:02












  • 7




    Reminds me of one alias I have: alias kk='ll'
    – RoVo
    May 16 at 7:42






  • 14




    I wouldn't recommend using at as an alias for cat. There's an actual command at for scheduling stuff: askubuntu.com/a/339301/295286
    – Sergiy Kolodyazhnyy
    May 16 at 8:02







7




7




Reminds me of one alias I have: alias kk='ll'
– RoVo
May 16 at 7:42




Reminds me of one alias I have: alias kk='ll'
– RoVo
May 16 at 7:42




14




14




I wouldn't recommend using at as an alias for cat. There's an actual command at for scheduling stuff: askubuntu.com/a/339301/295286
– Sergiy Kolodyazhnyy
May 16 at 8:02




I wouldn't recommend using at as an alias for cat. There's an actual command at for scheduling stuff: askubuntu.com/a/339301/295286
– Sergiy Kolodyazhnyy
May 16 at 8:02










2 Answers
2






active

oldest

votes

















up vote
17
down vote



accepted










The help for alias indicates that it can assign multiple aliases at once:



alias: alias [-p] [name[=value] ... ]
Define or display aliases.

Without arguments, `alias' prints the list of aliases in the reusable
form `alias NAME=VALUE' on standard output.

Otherwise, an alias is defined for each NAME whose VALUE is given.
A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.


So you can use brace expansion to generate the name=value pairs:



alias at,cart,cst='/bin/cat'


So:



$ alias at,cart,cst='/bin/cat'
$ type at cart cst
at is aliased to `/bin/cat'
cart is aliased to `/bin/cat'
cst is aliased to `/bin/cat'


That said, look in to zsh, which has built-in typo correction (which wouldn't help for at, but it would help for the others):




% setopt correct
% sl
zsh: correct `sl' to `ls' [nyae]? y
% setopt correctall
% ls x.v11r4
zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
/usr/princton/src/x.v11r4 not found
% ls /etc/paswd
zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
/etc/passwd


If you press y when the shell asks you if you want to correct a
word, it will be corrected. If you press n, it will be left alone.
Pressing a aborts the command, and pressing e brings the line up
for editing again, in case you agree the word is spelled wrong but you
don't like the correction.







share|improve this answer



























    up vote
    7
    down vote













    I don't think you can assign multiple aliases at once.

    But you could loop through a list like this:



    for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done


    Make sure that the aliases are not already in use by other programs (like at in your example).






    share|improve this answer






















    • Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
      – Josef Klimuk
      May 16 at 9:49






    • 2




      @JosefKlimuk: Sounds like it would be worth its own answer. :-)
      – David Foerster
      May 16 at 10:22










    • @David Foerster, Should I ask it as independent question?
      – Josef Klimuk
      May 16 at 10:37






    • 2




      @JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
      – David Foerster
      May 16 at 16:09










    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',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2faskubuntu.com%2fquestions%2f1036830%2fcreate-multiple-shell-aliases-at-once%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    17
    down vote



    accepted










    The help for alias indicates that it can assign multiple aliases at once:



    alias: alias [-p] [name[=value] ... ]
    Define or display aliases.

    Without arguments, `alias' prints the list of aliases in the reusable
    form `alias NAME=VALUE' on standard output.

    Otherwise, an alias is defined for each NAME whose VALUE is given.
    A trailing space in VALUE causes the next word to be checked for
    alias substitution when the alias is expanded.


    So you can use brace expansion to generate the name=value pairs:



    alias at,cart,cst='/bin/cat'


    So:



    $ alias at,cart,cst='/bin/cat'
    $ type at cart cst
    at is aliased to `/bin/cat'
    cart is aliased to `/bin/cat'
    cst is aliased to `/bin/cat'


    That said, look in to zsh, which has built-in typo correction (which wouldn't help for at, but it would help for the others):




    % setopt correct
    % sl
    zsh: correct `sl' to `ls' [nyae]? y
    % setopt correctall
    % ls x.v11r4
    zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
    /usr/princton/src/x.v11r4 not found
    % ls /etc/paswd
    zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
    /etc/passwd


    If you press y when the shell asks you if you want to correct a
    word, it will be corrected. If you press n, it will be left alone.
    Pressing a aborts the command, and pressing e brings the line up
    for editing again, in case you agree the word is spelled wrong but you
    don't like the correction.







    share|improve this answer
























      up vote
      17
      down vote



      accepted










      The help for alias indicates that it can assign multiple aliases at once:



      alias: alias [-p] [name[=value] ... ]
      Define or display aliases.

      Without arguments, `alias' prints the list of aliases in the reusable
      form `alias NAME=VALUE' on standard output.

      Otherwise, an alias is defined for each NAME whose VALUE is given.
      A trailing space in VALUE causes the next word to be checked for
      alias substitution when the alias is expanded.


      So you can use brace expansion to generate the name=value pairs:



      alias at,cart,cst='/bin/cat'


      So:



      $ alias at,cart,cst='/bin/cat'
      $ type at cart cst
      at is aliased to `/bin/cat'
      cart is aliased to `/bin/cat'
      cst is aliased to `/bin/cat'


      That said, look in to zsh, which has built-in typo correction (which wouldn't help for at, but it would help for the others):




      % setopt correct
      % sl
      zsh: correct `sl' to `ls' [nyae]? y
      % setopt correctall
      % ls x.v11r4
      zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
      /usr/princton/src/x.v11r4 not found
      % ls /etc/paswd
      zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
      /etc/passwd


      If you press y when the shell asks you if you want to correct a
      word, it will be corrected. If you press n, it will be left alone.
      Pressing a aborts the command, and pressing e brings the line up
      for editing again, in case you agree the word is spelled wrong but you
      don't like the correction.







      share|improve this answer






















        up vote
        17
        down vote



        accepted







        up vote
        17
        down vote



        accepted






        The help for alias indicates that it can assign multiple aliases at once:



        alias: alias [-p] [name[=value] ... ]
        Define or display aliases.

        Without arguments, `alias' prints the list of aliases in the reusable
        form `alias NAME=VALUE' on standard output.

        Otherwise, an alias is defined for each NAME whose VALUE is given.
        A trailing space in VALUE causes the next word to be checked for
        alias substitution when the alias is expanded.


        So you can use brace expansion to generate the name=value pairs:



        alias at,cart,cst='/bin/cat'


        So:



        $ alias at,cart,cst='/bin/cat'
        $ type at cart cst
        at is aliased to `/bin/cat'
        cart is aliased to `/bin/cat'
        cst is aliased to `/bin/cat'


        That said, look in to zsh, which has built-in typo correction (which wouldn't help for at, but it would help for the others):




        % setopt correct
        % sl
        zsh: correct `sl' to `ls' [nyae]? y
        % setopt correctall
        % ls x.v11r4
        zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
        /usr/princton/src/x.v11r4 not found
        % ls /etc/paswd
        zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
        /etc/passwd


        If you press y when the shell asks you if you want to correct a
        word, it will be corrected. If you press n, it will be left alone.
        Pressing a aborts the command, and pressing e brings the line up
        for editing again, in case you agree the word is spelled wrong but you
        don't like the correction.







        share|improve this answer












        The help for alias indicates that it can assign multiple aliases at once:



        alias: alias [-p] [name[=value] ... ]
        Define or display aliases.

        Without arguments, `alias' prints the list of aliases in the reusable
        form `alias NAME=VALUE' on standard output.

        Otherwise, an alias is defined for each NAME whose VALUE is given.
        A trailing space in VALUE causes the next word to be checked for
        alias substitution when the alias is expanded.


        So you can use brace expansion to generate the name=value pairs:



        alias at,cart,cst='/bin/cat'


        So:



        $ alias at,cart,cst='/bin/cat'
        $ type at cart cst
        at is aliased to `/bin/cat'
        cart is aliased to `/bin/cat'
        cst is aliased to `/bin/cat'


        That said, look in to zsh, which has built-in typo correction (which wouldn't help for at, but it would help for the others):




        % setopt correct
        % sl
        zsh: correct `sl' to `ls' [nyae]? y
        % setopt correctall
        % ls x.v11r4
        zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
        /usr/princton/src/x.v11r4 not found
        % ls /etc/paswd
        zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
        /etc/passwd


        If you press y when the shell asks you if you want to correct a
        word, it will be corrected. If you press n, it will be left alone.
        Pressing a aborts the command, and pressing e brings the line up
        for editing again, in case you agree the word is spelled wrong but you
        don't like the correction.








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 16 at 8:49









        muru

        129k19271460




        129k19271460






















            up vote
            7
            down vote













            I don't think you can assign multiple aliases at once.

            But you could loop through a list like this:



            for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done


            Make sure that the aliases are not already in use by other programs (like at in your example).






            share|improve this answer






















            • Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
              – Josef Klimuk
              May 16 at 9:49






            • 2




              @JosefKlimuk: Sounds like it would be worth its own answer. :-)
              – David Foerster
              May 16 at 10:22










            • @David Foerster, Should I ask it as independent question?
              – Josef Klimuk
              May 16 at 10:37






            • 2




              @JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
              – David Foerster
              May 16 at 16:09














            up vote
            7
            down vote













            I don't think you can assign multiple aliases at once.

            But you could loop through a list like this:



            for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done


            Make sure that the aliases are not already in use by other programs (like at in your example).






            share|improve this answer






















            • Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
              – Josef Klimuk
              May 16 at 9:49






            • 2




              @JosefKlimuk: Sounds like it would be worth its own answer. :-)
              – David Foerster
              May 16 at 10:22










            • @David Foerster, Should I ask it as independent question?
              – Josef Klimuk
              May 16 at 10:37






            • 2




              @JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
              – David Foerster
              May 16 at 16:09












            up vote
            7
            down vote










            up vote
            7
            down vote









            I don't think you can assign multiple aliases at once.

            But you could loop through a list like this:



            for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done


            Make sure that the aliases are not already in use by other programs (like at in your example).






            share|improve this answer














            I don't think you can assign multiple aliases at once.

            But you could loop through a list like this:



            for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done


            Make sure that the aliases are not already in use by other programs (like at in your example).







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 16 at 8:05

























            answered May 16 at 7:49









            RoVo

            4,756932




            4,756932











            • Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
              – Josef Klimuk
              May 16 at 9:49






            • 2




              @JosefKlimuk: Sounds like it would be worth its own answer. :-)
              – David Foerster
              May 16 at 10:22










            • @David Foerster, Should I ask it as independent question?
              – Josef Klimuk
              May 16 at 10:37






            • 2




              @JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
              – David Foerster
              May 16 at 16:09
















            • Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
              – Josef Klimuk
              May 16 at 9:49






            • 2




              @JosefKlimuk: Sounds like it would be worth its own answer. :-)
              – David Foerster
              May 16 at 10:22










            • @David Foerster, Should I ask it as independent question?
              – Josef Klimuk
              May 16 at 10:37






            • 2




              @JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
              – David Foerster
              May 16 at 16:09















            Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
            – Josef Klimuk
            May 16 at 9:49




            Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
            – Josef Klimuk
            May 16 at 9:49




            2




            2




            @JosefKlimuk: Sounds like it would be worth its own answer. :-)
            – David Foerster
            May 16 at 10:22




            @JosefKlimuk: Sounds like it would be worth its own answer. :-)
            – David Foerster
            May 16 at 10:22












            @David Foerster, Should I ask it as independent question?
            – Josef Klimuk
            May 16 at 10:37




            @David Foerster, Should I ask it as independent question?
            – Josef Klimuk
            May 16 at 10:37




            2




            2




            @JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
            – David Foerster
            May 16 at 16:09




            @JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
            – David Foerster
            May 16 at 16:09












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036830%2fcreate-multiple-shell-aliases-at-once%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Which professions warranted travel in Medieval times?

            How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

            Trouble downloading packages list due to a “Hash sum mismatch” error