File: esh-io.el.html
At the moment, only output redirection is supported in Eshell. To use input redirection, the following syntax will work, assuming that the command after the pipe is always an external command:
cat <file> | <command>
Otherwise, output redirection and piping are provided in a manner consistent with most shells. Therefore, only unique features are mentioned here.
;_* Redirect to a Buffer or Process
Buffers and processes can be named with '#<buffer buffer-name>' and
'#<process process-name>', respectively. As a shorthand,
'#<buffer-name>' without the explicit "buffer" arg is equivalent to
'#<buffer buffer-name>'.
echo hello > #<buffer *scratch*> # Overwrite '*scratch*' with 'hello'.
echo hello > #<*scratch*> # Same as the command above.
echo hello > #<process shell> # Pipe "hello" into the shell process.
;_* Insertion
To insert at the location of point in a buffer, use '>>>':
echo alpha >>> #<buffer *scratch*>;
;_* Pseudo-devices
A few pseudo-devices are provided, since Emacs cannot write directly to a UNIX device file:
echo alpha > /dev/null ; the bit bucket
echo alpha > /dev/kill ; set the kill ring
echo alpha >> /dev/clip ; append to the clipboard
;_* Multiple output targets
Eshell can write to multiple output targets, including pipes. Example:
(+ 1 2) > a > b > c ; prints number to all three files (+ 1 2) > a | wc ; prints to 'a', and pipes to 'wc'
Defined variables (9)
eshell-error-handle | The index of the standard error handle. |
eshell-io-load-hook | A hook that gets run when ‘eshell-io’ is loaded. |
eshell-last-command-result | The result of the last command. Not related to success. |
eshell-last-command-status | The exit code from the last command. 0 if successful. |
eshell-number-of-handles | The number of file handles that eshell supports. |
eshell-output-file-buffer | If non-nil, the current buffer is a file output buffer. |
eshell-output-handle | The index of the standard output handle. |
eshell-print-queue-size | The size of the print queue, for doing buffered printing. |
eshell-virtual-targets | Map virtual devices name to Emacs Lisp functions. |
Defined functions (22)
eshell--apply-redirections | (CMD) |
eshell-buffered-print | (&rest STRINGS) |
eshell-clipboard-append | (STRING) |
eshell-close-handles | (EXIT-CODE &optional RESULT HANDLES) |
eshell-close-target | (TARGET STATUS) |
eshell-create-handles | (STDOUT OUTPUT-MODE &optional STDERR ERROR-MODE) |
eshell-error | (OBJECT) |
eshell-errorn | (OBJECT) |
eshell-flush | (&optional RESET-P) |
eshell-get-target | (TARGET &optional MODE) |
eshell-init-print-buffer | () |
eshell-interactive-output-p | () |
eshell-io-initialize | () |
eshell-kill-append | (STRING) |
eshell-output-object | (OBJECT &optional HANDLE-INDEX HANDLES) |
eshell-output-object-to-target | (OBJECT TARGET) |
eshell-parse-redirection | () |
eshell-print | (OBJECT) |
eshell-printn | (OBJECT) |
eshell-protect-handles | (HANDLES) |
eshell-set-output-handle | (INDEX MODE &optional TARGET) |
eshell-strip-redirections | (TERMS) |