25 Mar 2024 ~ 1 min read
I don’t think I could live without all my alias commands. Most of the time, I add ones for Git commands, but every once in a while, you run into a complex command you need for Docker or a convoluted development process, like exposing a port for an Android device.
That's when they come in really handy. Anyhow, here's how you can create them on a Mac.
code ~/.bash_profile
. You can use any code editor you want; that is just my preferred option..bash_profile
file in your text editor.alias [shortcut]='[command]'
.[shortcut]
with the shortcut you want to use for the command, and [command]
with the command you want to execute.source ~/.bash_profile
in your terminal to reload the file and apply the changes.That's it! You've just created an alias for a terminal command. Now, whenever you type the shortcut, the command will be executed.
Here are some examples of aliases you can create to make your terminal commands faster and simpler:
alias ll='ls -alh'
- This creates an alias for the ls -alh
command, which lists all files in a directory in a long format with human-readable file sizes.alias gs='git status'
- This creates an alias for the git status
command, which displays the status of your Git repository.alias vs='code .'
- This creates an alias for opening the current directory in VS Code.Now you can create as many as you want and speed yourself up, reducing the number of complex commands you need to remember.
Well, that’s it. Talk to you later!