Alias (command)
In computing, alias is a command in various command-line interpreters (shells), which enables a replacement of a word by another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. alias is available in Unix shells, AmigaDOS, 4DOS/4NT, KolibriOS, Windows PowerShell, ReactOS, and the EFI shell. Aliasing functionality in the MS-DOS and Microsoft Windows operating systems is provided by the DOSKey command-line utility. An alias will last for the life of the shell session. Regularly used aliases can be set from the shell's rc file (such as .bashrc) so that they will be available upon the start of the corresponding shell session. The alias commands may either be written in the config file directly or sourced from a separate file. History In Unix, aliases were introduced in the C shell and survive in descendant shells such as tcsh and bash. C shell aliases were strictly limited to one line. This was useful for creating simple shortcut commands, but not more complex constructs. Older versions of the Bourne shell did not offer aliases, but it did provide functions, which are more powerful than the csh alias concept. The alias concept from csh was imported into Bourne Again Shell (bash) and the Korn shell (ksh). With shells that support both functions and aliases but no parameterized inline shell scripts, the use of functions wherever possible is recommended. Cases where aliases are necessary include situations where chained aliases are required (bash and ksh). The command has also been ported to the IBM i operating system. Usage Creating aliases Common Unix shells Non-persistent aliases can be created by supplying name/value pairs as arguments for the alias command. In Unix shells the syntax is: alias gc='git commit' C shell The corresponding syntax in the C shell or tcsh shell is: alias gc "git commit" This alias means that when the command gc is read in the shell, it will be replaced with git commit and that command will be executed instead. 4DOS In the 4DOS/4NT shell the following syntax is used to define cp as an alias for the 4DOS copy command: alias cp copy Windows PowerShell To create a new alias in Windows PowerShell, the new-alias cmdlet can be used: new-alias ci copy-item This creates a new alias called ci that will be replaced with the copy-item cmdlet when executed. In PowerShell, an alias cannot be used to specify default arguments for a command. Instead, this must be done by adding items to the collection $PSDefaultParameterValues, one of the PowerShell preference variables. Viewing currently defined aliases To view defined aliases the following commands can be used: alias # Used without arguments; displays a list of all current aliases alias -p # List aliases in a way that allows re-creation by sourcing the output; not available in 4DOS/4NT and PowerShell alias myAlias # Displays the command for a defined alias Overriding aliases In Unix shells, it is possible to override an alias by quoting any