Variable: eshell-virtual-targets

eshell-virtual-targets is a customizable variable defined in esh-io.el.gz.

Value

(("/dev/null" (lambda (_mode) (throw 'eshell-null-device t)) t)
 ("/dev/eshell" eshell-interactive-print nil)
 ("/dev/kill"
  (lambda (mode) (when (eq mode 'overwrite) (kill-new ""))
    #'eshell-kill-append)
  t)
 ("/dev/clip"
  (lambda (mode)
    (when (eq mode 'overwrite)
      (let ((select-enable-clipboard t)) (kill-new "")))
    #'eshell-clipboard-append)
  t))

Documentation

Map virtual devices name to Emacs Lisp functions.

Each member is of the following form:

  (FILENAME OUTPUT-FUNCTION [PASS-MODE])

When the user specifies FILENAME as a redirection target, Eshell will repeatedly call the OUTPUT-FUNCTION with the redirected output as strings. OUTPUT-FUNCTION can also be an eshell-generic-target instance. In this case, Eshell will repeatedly call the function in the output-function slot with the string output; once the redirection has completed, Eshell will then call the function in the close-function slot, passing the exit status of the redirected command.

If PASS-MODE is non-nil, Eshell will pass the redirection mode as an argument (which is the symbol overwrite, append or insert) to OUTPUT-FUNCTION, which should return the real output function (either an ordinary function or eshell-generic-target as described above).

This variable was added, or its default value changed, in Emacs 30.1.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-io.el.gz
(defcustom eshell-virtual-targets
  '(;; The literal string "/dev/null" is intentional here.  It just
    ;; provides compatibility so that users can redirect to
    ;; "/dev/null" no matter the actual value of `null-device'.
    ("/dev/null" (lambda (_mode) (throw 'eshell-null-device t)) t)
    ("/dev/eshell" eshell-interactive-print nil)
    ("/dev/kill" (lambda (mode)
                   (when (eq mode 'overwrite)
                     (kill-new ""))
                   #'eshell-kill-append)
     t)
    ("/dev/clip" (lambda (mode)
                   (when (eq mode 'overwrite)
                     (let ((select-enable-clipboard t))
                       (kill-new "")))
                   #'eshell-clipboard-append)
     t))
  "Map virtual devices name to Emacs Lisp functions.
Each member is of the following form:

  (FILENAME OUTPUT-FUNCTION [PASS-MODE])

When the user specifies FILENAME as a redirection target, Eshell will
repeatedly call the OUTPUT-FUNCTION with the redirected output as
strings.  OUTPUT-FUNCTION can also be an `eshell-generic-target'
instance.  In this case, Eshell will repeatedly call the function in the
`output-function' slot with the string output; once the redirection has
completed, Eshell will then call the function in the `close-function'
slot, passing the exit status of the redirected command.

If PASS-MODE is non-nil, Eshell will pass the redirection mode as an
argument (which is the symbol `overwrite', `append' or `insert') to
OUTPUT-FUNCTION, which should return the real output function (either an
ordinary function or `eshell-generic-target' as described above)."
  :version "30.1"
  :type '(repeat
	  (list (string :tag "Target")
		function
		(choice (const :tag "Func returns output-func" t)
			(const :tag "Func is output-func" nil))))
  :risky t
  :group 'eshell-io)