How to create Bash alias with parameters?

As for me, I’m constantly typing a couple of commands into the console. And some of these commands contain parameters. So, I’ve decided to create an alias for them. But how to create an alias with parameters? It’s simple:

$ vim ~/.bash_profile # or .bashrc
# Add something like:
helloWorld() {
 echo "Hi $@" # Or $1 - if you want just the first argument
$ source ~/.bash_profile # Either close and open terminal or simply reload settings
$ helloWorld John Doe
Hi John Doe

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *