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.
$#VARIABLE
Returns the length of the value of VARIABLE. This could also be
done using the length Lisp function.
$(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.
$ANYVAR[10]
Return the 10th element of ANYVAR. If ANYVAR's value is a string, it will be split in order to make it a list. The splitting will occur at whitespace.
$ANYVAR[: 10]
As above, except that splitting occurs at the colon now.
$ANYVAR[: 10 20]
As above, but instead of returning just a string, it now returns a list of two strings. If the result is being interpolated into a larger string, this list will be flattened into one big string, with each element separated by a space.
$ANYVAR["\\\\\\\\" 10]
Separate on backslash characters. Actually, the first argument --
if it doesn't have the form of a number, or a plain variable name
-- can be any regular expression. So to split on numbers, use
'$ANYVAR["[0-9]+" 10 20]'.
$ANYVAR[hello]
Calls assoc on ANYVAR with 'hello', expecting it to be an alist.
$#ANYVAR[hello]
Returns the length of the cdr of the element of ANYVAR who car is equal to "hello".
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 (8)
eshell-complete-export-definition | If non-nil, completing names for ‘export’ shows current definition. |
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 (24)
eshell-apply-indices | (VALUE INDICES) |
eshell-complete-variable-assignment | () |
eshell-complete-variable-reference | () |
eshell-environment-variables | () |
eshell-envvar-names | (&optional ENVIRONMENT) |
eshell-get-variable | (NAME &optional INDICES) |
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 | () |
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/setq | (&rest ARGS) |
eshell/unset | (&rest ARGS) |
pcomplete/eshell-mode/export | () |
pcomplete/eshell-mode/setq | () |
pcomplete/eshell-mode/unset | () |