Assuming you use bash, there are many ways to do this as mentioned above. Here is what I found to be the most convenient - YMMV:
- Create a function for each "shortcut" that you want to use.
- Have all such functions in a file called, say,
- Source this file in your
- Call the function followed by the argument(s).
Note that, strictly speaking, the file doesn't contain aliases, but I am using that name to keep things uncluttered. You might want to call it .bash_functions.
Here is an extremely simple example to get you started. It doesn't check if you have actually passed on an argument or not.
$ cat ~/.bash_aliases
sudo docker "$@"
You can then add a line in your
.bash_profile to source it like so:
Here are some sample usages:
g commit -m 'initial commit' fileName
sudock run my-repo/my-image
Note that you can use $1 in place of $@, but that will take only one argument instead of considering everything that was passed on to the function.