6

I understand why eshell provides elisp interpretations of the kill and rm commands, however, I would like Emacs to use the operating-specific implementations if they are available in the $PATH (especially in the case of rm, because the elisp implementation of rm can take minutes to delete large directories of files).

How can I tell Emacs to use the rm command in $PATH if available, and only fall back to the elisp implementation if not found?

Lee H
  • 2,727
  • 1
  • 17
  • 31

2 Answers2

6

If it's just for a single invocation then, as per the eshell manual (look for the "Built-in commands" section), you can prefix any command with '*' to ignore the built-ins:

$ which ls
eshell/ls is a compiled Lisp function in `em-ls.el'

Compared with:

$ which *ls
/usr/bin/ls

That same page has the tip that if you wanted to always do this (say for your rm example), you could define a permanent alias:

$ alias rm '*rm $*'
$ which rm
/usr/bin/rm
Boccaperta-IT
  • 1,556
  • 11
  • 24
Stuart Hickinbottom
  • 2,423
  • 16
  • 17
0

shameless plug

This is not exactly the solution to your problem, but I think is close enough for you to consider it if a better answer doesn't show up. I wrote an extension a while back, shell-ext, which works with shell-mode rather than eshell, but it intercepts the commands before being executed, letting you do whatever you want with it, like calling a different command based on OS. It relies on a hook that shell-mode provides to get the input. If eshell provides a similar hook you could use the same mechanism.

rlazo
  • 993
  • 8
  • 13