File: esh-var.el.html
These are the possible variable interpolation syntaxes. Also keep in mind that if an argument looks like a number, it will be converted to a number. This is not significant when invoking external commands, but it's important when calling Lisp functions.
$VARIABLE
Interval the value of an environment variable, or a Lisp variable
$ALSO-VAR
"-" is a valid part of a variable name.
$\"MYVAR\\"-TOO
$'MYVAR'-TOO
Only "MYVAR" is part of the variable name in this case.
$(lisp)
Returns result of Lisp evaluation. Note: Used alone like this, it
is identical to just saying (lisp); but with the variable expansion
form, the result may be interpolated a larger string, such as
'$(lisp)/other'.
${command}
Returns the value of an eshell subcommand. See the note above regarding Lisp evaluations.
$<command>
Evaluates an eshell subcommand, redirecting the output to a temporary file, and returning the file name.
$EXPR[10]
Return the 10th element of $EXPR, which can be any dollar expression. If $EXPR's value is a string, it will be split in order to make it a list. The splitting will occur at whitespace.
$EXPR[10 20]
As above, but instead of returning a single element, it now returns a list of two elements.
$EXPR[: 10]
Like $EXPR[10], except that splitting occurs at the colon now.
$EXPR["\\\\\\\\" 10]
Separate on backslash characters. Actually, the first argument -- if it doesn't have the form of a number -- can be any regular expression. So to split on numbers, use '$EXPR["[0-9]+" 10 20]'.
$EXPR[hello]
Calls assoc on $EXPR with 'hello', expecting it to be an alist.
$#EXPR
Returns the length of the value of $EXPR. This could also be
done using the length Lisp function.
There are also a few special variables defined by Eshell. '$$' is the value of the last command (t or nil, in the case of an external command). This makes it possible to chain results:
/tmp $ echo /var/spool/mail/johnw
/var/spool/mail/johnw
/tmp $ dirname $$
/var/spool/mail/
/tmp $ cd $$
/var/spool/mail $
'$_' refers to the last argument of the last command. And $?
contains the exit code of the last command (0 or 1 for Lisp
functions, based on successful completion).
Defined variables (9)
eshell-complete-export-definition | If non-nil, completing names for ‘export’ shows current definition. |
eshell-inside-emacs | Value for the ‘INSIDE_EMACS’ environment variable. |
eshell-modify-global-environment | If non-nil, using ‘export’ changes Emacs’s global environment. |
eshell-prefer-lisp-variables | If non-nil, prefer Lisp variables to environment variables. |
eshell-var-load-hook | A list of functions to call when loading ‘eshell-var’. |
eshell-var-mode | Non-nil if Eshell-Var mode is enabled. |
eshell-var-mode-hook | Hook run after entering or leaving ‘eshell-var-mode’. |
eshell-variable-aliases-list | This list provides aliasing for variable references. |
eshell-variable-name-regexp | A regexp identifying what constitutes a variable name reference. |
Defined functions (28)
eshell-apply-indices | (VALUE INDICES &optional QUOTED) |
eshell-complete-variable-assignment | () |
eshell-complete-variable-reference | () |
eshell-environment-variables | () |
eshell-envvar-names | (&optional ENVIRONMENT) |
eshell-eval-indices | (INDICES) |
eshell-get-variable | (NAME &optional INDICES QUOTED) |
eshell-handle-local-variables | () |
eshell-index-value | (VALUE INDEX) |
eshell-insert-envvar | (ENVVAR-NAME) |
eshell-interpolate-variable | () |
eshell-parse-indices | () |
eshell-parse-variable | () |
eshell-parse-variable-ref | (&optional MODIFIER-P) |
eshell-set-variable | (NAME VALUE) |
eshell-var-initialize | () |
eshell-var-mode | (&optional ARG) |
eshell-variables-list | () |
eshell/define | (VAR-ALIAS DEFINITION) |
eshell/env | (&rest ARGS) |
eshell/export | (&rest SETS) |
eshell/set | (&rest ARGS) |
eshell/setq | (&rest ARGS) |
eshell/unset | (&rest ARGS) |
pcomplete/eshell-mode/export | () |
pcomplete/eshell-mode/set | () |
pcomplete/eshell-mode/setq | () |
pcomplete/eshell-mode/unset | () |