Search code examples
bashbash-completion

Command wrapper and completion


I often write something like this:

cp -r folder-0.0.1 ~/temp
cp -r folder-0.2.2 ~/temp
cp -r folder-1.0.0 ~/temp

Template: <comand> <name>-<version> <path>

But instead, I'd like to write this:

do_something 0.0.1
do_something 0.2.2
do_something 1.0.0

Template: <alias> <version>

Can I do it easily in using aliases?

I would also like appropriate completion with tab key to work correctly. How can I program 's completion to achieve this?


Solution

  • Not with aliases.

    do_something () {
      cp -r folder-"$1" ~/temp
    }