An alias allows you to associate a command with a custom name. One use of aliases is to add a shortcut to launch an application.
Step 1: What shell am I using?
First we need to find out which shell you are using. Launch the Terminal from
/Applications/Utilities and run:
If the above returns
/bin/zsh your shell is zsh, if
/bin/bash is returned your shell is bash.
Step 2: Open the shells configuration file
We will add our aliases to the shells configuration file using nano. Nano is a simple command line editor.
To open your shell configuration file run:
#zsh nano ~/.zshrc #bash nano ~/.bashrc
If this file does not exist, create it by running:
#zsh touch ~/.zshrc #bash touch ~/.bashrc
Step 3: Add an alias
We are now ready to add an aliases. For example, to use 'vsc' to open Visual Studio Code add:
alias vsc="open -a Visual \Studio \Code"
Once you have finished, use
^X to exit nano.
Step 4: Refresh shell environment
You'll need to refresh the shell environment for the alias to take effect.
#zsh source ~/.zshrc #bash source ~/.bashrc