alias works very well in Eshell. I've used it like this:

alias sau sudo aptitude update

However, it doesn't work for the search command:

$ alias aps aptitude search 
$ aps emacs
search: You must provide at least one search term

What's wrong with this?


In short: use alias aps 'aptitude search $*' (quotes seem to be important).

The comment at the top of em-alias.el says the following.

Creating aliases

The user interface is simple: type alias followed by the command name followed by the definition. Argument references are made using $1, $2, etc., or $*. For example:

alias ll 'ls -l $*'

This will cause the command ll NEWS to be replaced by ls -l NEWS. This is then passed back to the command parser for reparsing.{Only the command text specified in the alias definition will be reparsed. Argument references (such as $*) are handled using variable values, which means that the expansion will not be reparsed, but used directly.}

To delete an alias, specify its name without a definition:

alias ll

Aliases are written to disk immediately after being defined or deleted. The filename in which they are kept is defined by the variable eshell-aliases-file.

  • Wow, that works. You also answered my other problem: delete alias. Thank you for your detailed answer.
    – Nick
    Dec 24 '14 at 8:00
  • @Constantine This is from the "Aliases" node in eshell's info doc. "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'." - so why does this definition of ll` work?
    – Pradhan
    Dec 24 '14 at 17:18
  • 1
    @Pradhan: Yes, I read the info docs too. As far as I can tell, after running alias ll ls -l ll foo runs ls -l, not ls -l foo, i.e. the argument is ignored. I am pretty sure this is a documentation bug. (Note that this section of the manual uses the syntax described in the comment I quoted (look for "sudo").) Dec 24 '14 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.