alias
?alias
is a shortcut command that performs functions as if we typed the entire command.
alias
?While executing commands, the alias
command directs the shell
to substitute one string with another string. Instead of typing the long command every time, we construct an alias/shortcut.
Permanent aliases can be created by adding the alias to the
bashrc
file for the bash shell, or thezshrc
file for thezsh
shell.
alias shortcut_name = command
shortcut_name
is the short form of the command you wish to use. When executing, shortcut_name
will be replaced with the command.
For example:
alias gc="git commit -m 'First Commit'"
When the gc
string is run in the terminal, git commit -m 'First Commit'
is executed.
Running the
alias
command lists all the available aliases configured in the system.
In the above terminal, we define two aliases. One uses the echo
command to print hello-educative
, and the other prints the current date
and time
in the system.