.bashrc alias for a command with fixed second parameter Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How to run some alias command in bash's non-interactive modeSaw an interesting command but can't alias itHow to alias one command to be resolved into another command?argument-aware alias command?Alias for gnome-open to open different filesCan I pass arguments to an alias command?Catch user input with aliasModify the “alert” alias in ~/.bashrcHow to set an Alias in bashrc so that System IP can be found using a simple alias command?Bash_alias, run a script with a parameter and close console

Marquee sign letters

Why do C and C++ allow the expression (int) + 4*5?

Is there a verb for listening stealthily?

Can a Wizard take the Magic Initiate feat and select spells from the Wizard list?

Why do people think Winterfell crypts is the safest place for women, children & old people?

Help Recreating a Table

A German immigrant ancestor has a "Registration Affidavit of Alien Enemy" on file. What does that mean exactly?

Can gravitational waves pass through a black hole?

Recursive calls to a function - why is the address of the parameter passed to it lowering with each call?

How was Lagrange appointed professor of mathematics so early?

Does the Pact of the Blade warlock feature allow me to customize the properties of the pact weapon I create?

Determine the generator of an ideal of ring of integers

Pointing to problems without suggesting solutions

What's the difference between using dependency injection with a container and using a service locator?

Converting a text document with special format to Pandas DataFrame

Coin Game with infinite paradox

How to create a command for the "strange m" symbol in latex?

How to mute a string and play another at the same time

Is the Mordenkainen's Sword spell underpowered?

What helicopter has the most rotor blades?

What is the evidence that custom checks in Northern Ireland are going to result in violence?

How to make an animal which can only breed for a certain number of generations?

What is the definining line between a helicopter and a drone a person can ride in?

Knights and Knaves question



.bashrc alias for a command with fixed second parameter



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How to run some alias command in bash's non-interactive modeSaw an interesting command but can't alias itHow to alias one command to be resolved into another command?argument-aware alias command?Alias for gnome-open to open different filesCan I pass arguments to an alias command?Catch user input with aliasModify the “alert” alias in ~/.bashrcHow to set an Alias in bashrc so that System IP can be found using a simple alias command?Bash_alias, run a script with a parameter and close console



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








3















I would like to create an alias for the move command -



trash='mv <some files> /home/$USER/.local/share/Trash/files'



How do I make this work?



I want the destination to always be the same. But I want to be able to pass the files to be moved.










share|improve this question

















  • 2





    There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

    – steeldriver
    yesterday

















3















I would like to create an alias for the move command -



trash='mv <some files> /home/$USER/.local/share/Trash/files'



How do I make this work?



I want the destination to always be the same. But I want to be able to pass the files to be moved.










share|improve this question

















  • 2





    There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

    – steeldriver
    yesterday













3












3








3


1






I would like to create an alias for the move command -



trash='mv <some files> /home/$USER/.local/share/Trash/files'



How do I make this work?



I want the destination to always be the same. But I want to be able to pass the files to be moved.










share|improve this question














I would like to create an alias for the move command -



trash='mv <some files> /home/$USER/.local/share/Trash/files'



How do I make this work?



I want the destination to always be the same. But I want to be able to pass the files to be moved.







bash






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









charsicharsi

18817




18817







  • 2





    There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

    – steeldriver
    yesterday












  • 2





    There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

    – steeldriver
    yesterday







2




2





There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

– steeldriver
yesterday





There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

– steeldriver
yesterday










2 Answers
2






active

oldest

votes


















9














Use function instead of alias, defined in .bashrc



nano ~/.bashrc 

# put inside .bashrc:
trash()
for item in "$@" ; do
echo "Trashing: $item"
mv "$item" /home/$USER/.local/share/Trash/files
done



Then in shell prompt you can use:



$ trash file1 file2





share|improve this answer























  • thanks! This worked perfectly.

    – charsi
    yesterday











  • Don't forget to close shell and open again to make this work

    – LeonidMew
    yesterday











  • source ~/.bashrc works too

    – charsi
    yesterday







  • 5





    You don't need a loop: trash() mv "$@" destination;

    – glenn jackman
    yesterday


















5














You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



alias trash='mv -t ~/.local/share/Trash/files'





share|improve this answer























    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%2f1135728%2fbashrc-alias-for-a-command-with-fixed-second-parameter%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









    9














    Use function instead of alias, defined in .bashrc



    nano ~/.bashrc 

    # put inside .bashrc:
    trash()
    for item in "$@" ; do
    echo "Trashing: $item"
    mv "$item" /home/$USER/.local/share/Trash/files
    done



    Then in shell prompt you can use:



    $ trash file1 file2





    share|improve this answer























    • thanks! This worked perfectly.

      – charsi
      yesterday











    • Don't forget to close shell and open again to make this work

      – LeonidMew
      yesterday











    • source ~/.bashrc works too

      – charsi
      yesterday







    • 5





      You don't need a loop: trash() mv "$@" destination;

      – glenn jackman
      yesterday















    9














    Use function instead of alias, defined in .bashrc



    nano ~/.bashrc 

    # put inside .bashrc:
    trash()
    for item in "$@" ; do
    echo "Trashing: $item"
    mv "$item" /home/$USER/.local/share/Trash/files
    done



    Then in shell prompt you can use:



    $ trash file1 file2





    share|improve this answer























    • thanks! This worked perfectly.

      – charsi
      yesterday











    • Don't forget to close shell and open again to make this work

      – LeonidMew
      yesterday











    • source ~/.bashrc works too

      – charsi
      yesterday







    • 5





      You don't need a loop: trash() mv "$@" destination;

      – glenn jackman
      yesterday













    9












    9








    9







    Use function instead of alias, defined in .bashrc



    nano ~/.bashrc 

    # put inside .bashrc:
    trash()
    for item in "$@" ; do
    echo "Trashing: $item"
    mv "$item" /home/$USER/.local/share/Trash/files
    done



    Then in shell prompt you can use:



    $ trash file1 file2





    share|improve this answer













    Use function instead of alias, defined in .bashrc



    nano ~/.bashrc 

    # put inside .bashrc:
    trash()
    for item in "$@" ; do
    echo "Trashing: $item"
    mv "$item" /home/$USER/.local/share/Trash/files
    done



    Then in shell prompt you can use:



    $ trash file1 file2






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered yesterday









    LeonidMewLeonidMew

    1,200624




    1,200624












    • thanks! This worked perfectly.

      – charsi
      yesterday











    • Don't forget to close shell and open again to make this work

      – LeonidMew
      yesterday











    • source ~/.bashrc works too

      – charsi
      yesterday







    • 5





      You don't need a loop: trash() mv "$@" destination;

      – glenn jackman
      yesterday

















    • thanks! This worked perfectly.

      – charsi
      yesterday











    • Don't forget to close shell and open again to make this work

      – LeonidMew
      yesterday











    • source ~/.bashrc works too

      – charsi
      yesterday







    • 5





      You don't need a loop: trash() mv "$@" destination;

      – glenn jackman
      yesterday
















    thanks! This worked perfectly.

    – charsi
    yesterday





    thanks! This worked perfectly.

    – charsi
    yesterday













    Don't forget to close shell and open again to make this work

    – LeonidMew
    yesterday





    Don't forget to close shell and open again to make this work

    – LeonidMew
    yesterday













    source ~/.bashrc works too

    – charsi
    yesterday






    source ~/.bashrc works too

    – charsi
    yesterday





    5




    5





    You don't need a loop: trash() mv "$@" destination;

    – glenn jackman
    yesterday





    You don't need a loop: trash() mv "$@" destination;

    – glenn jackman
    yesterday













    5














    You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



    alias trash='mv -t ~/.local/share/Trash/files'





    share|improve this answer



























      5














      You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



      alias trash='mv -t ~/.local/share/Trash/files'





      share|improve this answer

























        5












        5








        5







        You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



        alias trash='mv -t ~/.local/share/Trash/files'





        share|improve this answer













        You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



        alias trash='mv -t ~/.local/share/Trash/files'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        glenn jackmanglenn jackman

        12.9k2545




        12.9k2545



























            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%2f1135728%2fbashrc-alias-for-a-command-with-fixed-second-parameter%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

            How does Billy Russo acquire his 'Jigsaw' mask? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why does Bane wear the mask?Why does Kylo Ren wear a mask?Why did Captain America remove his mask while fighting Batroc the Leaper?How did the OA acquire her wisdom?Is Billy Breckenridge gay?How does Adrian Toomes hide his earnings from the IRS?What is the state of affairs on Nootka Sound by the end of season 1?How did Tia Dalma acquire Captain Barbossa's body?How is one “Deemed Worthy”, to acquire the Greatsword “Dawn”?How did Karen acquire the handgun?

            Личност Атрибути на личността | Литература и източници | НавигацияРаждането на личносттаредактиратередактирате

            A sequel to Domino's tragic life Why Christmas is for Friends Cold comfort at Charles' padSad farewell for Lady JanePS Most watched News videos