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.

  $@EXPR

Splices the value of $EXPR in-place into the current list of arguments. This is analogous to the ,@ token in Elisp backquotes, and works as if the user typed '$EXPR[0] $EXPR[1]
... $EXPR[N]'.

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 (11)

eshell-complete-export-definitionIf non-nil, completing names for ‘export’ shows current definition.
eshell-in-local-scope-pNon-nil if the current command has a local variable scope.
eshell-inside-emacsValue for the ‘INSIDE_EMACS’ environment variable.
eshell-local-variable-bindingsA list of ‘let’ bindings for local variable (and subcommand) environments.
eshell-modify-global-environmentIf non-nil, using ‘export’ changes Emacs’s global environment.
eshell-prefer-lisp-variablesIf non-nil, prefer Lisp variables to environment variables.
eshell-var-load-hookA list of functions to call when loading ‘eshell-var’.
eshell-var-modeNon-nil if Eshell-Var mode is enabled.
eshell-var-mode-hookHook run after entering or leaving ‘eshell-var-mode’.
eshell-variable-aliases-listThis list provides aliasing for variable references.
eshell-variable-name-regexpA regexp identifying what constitutes a variable name reference.

Defined functions (32)

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-range--pcase-macroexpander(START END)
eshell-index-value(VALUE INDEX)
eshell-insert-envvar(ENVVAR-NAME)
eshell-interpolate-variable()
eshell-parse-index(INDEX)
eshell-parse-indices()
eshell-parse-local-variables(ARGS)
eshell-parse-variable()
eshell-parse-variable-ref(&optional MODIFIER-P)
eshell-prepare-indices(INDICES)
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()

Defined faces (0)