In MacOS, you can create alias for long command for better typing and developing purposes!
In this post, you'll know how. In this instruction, we will do "pn" for "pnpm" command.
1. Identify Your Shell1. Identify Your Shell
1. Identify Your Shell1. Identify Your Shell
First, determine which shell you're using. Open your Terminal and run:
bash
echo $SHELL
This will likely output either /bin/zsh (for Zsh, the default in recent macOS versions) or /bin/bash (for Bash).
2. Edit the Correct Configuration File2. Edit the Correct Configuration File
2. Edit the Correct Configuration File2. Edit the Correct Configuration File
Based on your shell, you'll need to edit the corresponding configuration file.
bash
nano ~/.zshrc
For Zsh
bash
nano ~/.zshrc
For Zsh
3. Add the Alias3. Add the Alias
3. Add the Alias3. Add the Alias
Add the following line to the end of the file:
bash
alias pn="pnpm"
After adding the line, save the file and exit the editor by pressing
Ctrl + X, then Y, and finally Enter.4. Apply the Changes4. Apply the Changes
4. Apply the Changes4. Apply the Changes
For the new alias to take effect, you can either close and reopen your Terminal or run the
source command on your configuration file:bash
source ~/.zshrc
For Zsh
bash
source ~/.bash_profile
For Bash
Now, you can type
pn in your terminal, and it will execute the pnpm command.
