DEV Community

Discussion on: Aliases: Making the command line your friend

Collapse
 
filix profile image
Filip Ilić

After reading this I was interested how to make alias with variable, so I googled it and find out you can use functions since aliases do not support variable.

Put this inside function in your .bashrc or .zshrc file:

mtd () { mv "$@" /path/to/documents/; }

To move file.md to documents just use:

 file.md 

Or... you can put the function in an alias:

alias mtd='mvtd () { mv "$@" /path/to/documents/; }; mvtd;'