Alias a long terminal command in OSX
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I routinely use a long command in the terminal, and I'd like to alias it so that I can simply type 'my-command' to execute it.

Please provide clear instructions on how to set that up.

Thanks!

awarded to alex
Tags
osx

Crowdsource coding tasks.

1 Solution

Winning solution

For example if your command was

cd /Users/someone/path/to/somthing
ls

you could type alias openfile='cd /Users/someone/path/to/somthing; ls' and from now on you can run the openfile command to list the files inside /Users/someone/path/to/something. You can also edit the .bash_profile file inside your home directory to add/remove aliases. To do that, you could follow this guide here.