An alias helps you to produce a route name for a command, file name, or any shell text. By victimisation of aliases, you save heaps of your time once doing tasks that you were doing frequently.
What is an alias? ๐ค
The alias Korn shell integrated command to outline a phrase as an alias/shortcut for a few command. You can use aliases to redefine integrated or complex instructions except not to redefine reserved words.
Syntax:
alias [ -t ] [ -x ] [ AliasName [ =String ] ] ...
Flags:
-t - Sets or displays all existing tracked aliases
-x - Displays all existing exported alias definitions
Exit Status:
0 - Success
>0 - An error occurred
Example ๐๐ป
alias gs='git status'
How to configure alias in macOS? ๐ง๐ปโ๐ป
- Open terminal
- Type
code ~/.zshrc
which opens the zsh config file in VSCode - Configure your alias by following the above syntax and flags
Examples of my aliases:
alias gc='git commit -s -m'
alias gs='git status'
alias ga='git add'
alias gfu='git fetch upstream'
alias grum='git rebase upstream/master'
alias gpom='git push origin master'
alias gul='git fetch upstream && git rebase upstream/master && git push origin master'
alias gpo='git push origin'
- Save the file by clicking
cmd + s
- Now in your terminal, type
source ~/.zshrc
, which you applies the content of the file to the currently running Zsh process.
You are good to go ๐
You can test your alias if its working by entering a repo in your machine and running gs
If you want to learn more about alias and its configuration, you can refer to, https://man7.org/linux/man-pages/man1/alias.1p.html#:~:text=An%20alias%20definition%20provides%20a,subshells%20of%20the%20current%20shell.
Top comments (0)