eshell-named-command-hook
eshell-named-command-hook is a variable defined in `
esh-cmd.el
'.
Its value is
nil
- This variable may be risky if used as a file-local variable.
Documentation:
A set of functions called before a named command is invoked.
Each function will be passed the command name and arguments that were
passed to `eshell-named-command'.
If any of the functions returns a non-nil value, the named command
will not be invoked, and that value will be returned from
`eshell-named-command'.
In order to substitute an alternate command form for execution, the
hook function should throw it using the tag `eshell-replace-command'.
For example:
(add-hook 'eshell-named-command-hook 'subst-with-cd)
(defun subst-with-cd (command args)
(throw 'eshell-replace-command
(eshell-parse-command "cd" args)))
Although useless, the above code will cause any non-glob, non-Lisp
command (i.e., 'ls' as opposed to '*ls' or '(ls)') to be replaced by a
call to `cd' using the arguments that were passed to the function.
You can customize this variable.