Next: , Previous: Variables, Up: Commands

2.5 Aliases

Aliases are commands that expand to a longer input line. For example, ll is a common alias for ls -l, and would be defined with the command invocation alias ll 'ls -l $*'; with this defined, running ‘ll foo’ in Eshell will actually run ‘ls -l foo’. Aliases defined (or deleted) by the alias command are automatically written to the file named by eshell-aliases-file, which you can also edit directly (although you will have to manually reload it).

Note that unlike aliases in Bash, arguments must be handled explicitly. Typically the alias definition would end in ‘$*’ to pass all arguments along. More selective use of arguments via ‘$1’, ‘$2’, etc., is also possible. For example, alias mcd 'mkdir $1 && cd $1' would cause mcd foo to create and switch to a directory called ‘foo’.