1

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?

1 Answer 1

4

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.

3
  • Wow, that works. You also answered my other problem: delete alias. Thank you for your detailed answer.
    – Nick
    Commented Dec 24, 2014 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
    Commented Dec 24, 2014 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").) Commented Dec 24, 2014 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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