Creating alias for Trash
First of all, you don’t use $
when you call an alias.
$
is for expanding a variable (and a few other things
that aren’t particularly relevant to this question).
But, secondly, aliases do work a little like variables,
in the sense that they (at the risk of oversimplifying a little)
just expand to a bunch of words.
You say you want to do myrm foo
,
but that would expand to mv /home/user/Trash/* foo
,
which doesn’t make sense.
A simple solution would be
to define the alias to be mv -t /home/user/Trash
,
which would work because mv
supports the
mv -t destination_dir file …syntax as an alternative to the
mv file … destination_dirsyntax.
But you can get greater flexibility with a shell function. These combine the flexibility of scripts with the (low) overhead of aliases. For example,
myrm() { mv "$@" /home/user/Trash; }
will cause myrm foo
to be interpreted as mv foo /home/user/Trash
.
Probably easier solution is to use trash-cli
package. Then you can just do alias myrm=trash
and then trash foo
to accomplish what you want to. Except that foo will now go to ~/. local/share/Trash
The problem is, with mv
you have to use it like mv source destination
.
With your alias it's vice-versa mv destination source
.
Also you don't need the asterisk *
at the end, because it works with the destination as a folder. Make sure your folder /home/user/Trash
exists with mkdir /home/user/Trash
.
To solve your alias idea, I would recommend you to have a look at this stackoverflow questions:
- https://stackoverflow.com/q/7131670/7311363
This will lead to that solution; please add this to your ~/.bashrc
and do a source ~/.bashrc
after adding:
myrm() {
/bin/mv "$@" /home/user/Trash/
}