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?

2 Answers 2

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
2
  • I was about to post the same answer. :) Commented Oct 8, 2014 at 13:53
  • @Boccaperta-IT: then I won the karma-race! (it doesn't often happen to me!) Commented Oct 8, 2014 at 13:55
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.

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.