Creating aliases with OSX

September 2018

You can use aliases to set shortcuts to complex terminal commands. This is how:

  1. In Terminal, run
      cd && open -e .bash_profile
  2. In the opened file, add your alias. For this example, I’ll make a command zeph that opens this website in a browser:
      alias zeph="open ''"
  3. Save the file.

  4. Restart Terminal.

  5. Now you can run your command.

Using && to chain commands

You can use && to chain commands. However, pay attention to blocking operations:

# incorrect
jekyll serve && code .

This won’t open VS Code until you stop the server. You’ll need to reverse them:

# correct
code . && jekyll serve

Using &&, you could set an alias that opens VS Code to your working directory, opens your browser to localhost:3000, and spins up an npm server when you type work. The possibilities are limitless.