Variable: eshell-variable-aliases-list

eshell-variable-aliases-list is a customizable variable defined in esh-var.el.gz.

Value

Large value
(("COLUMNS" #[0 "\300\301\302\"\207" [window-body-width nil remap] 3]
  t t)
 ("LINES" #[0 "\300\301\302\"\207" [window-body-height nil remap] 3] t
  t)
 ("INSIDE_EMACS" eshell-inside-emacs t)
 ("PAGER"
  (#[0 "\206�\301\302!\207" [comint-pager getenv "PAGER"] 2]
   . #[514 "\211\204�\301\302!\210\211\211\207"
	   [comint-pager setenv "PAGER"] 4
	   ("/nix/store/yvwy8dm26cpa1j12ixgs1dyiaw2abdk9-emacs-snapshot/share/emacs/31.0.50/lisp/eshell/esh-var.elc"
	    . 2966)])
  t t)
 ("UID" #[0 "\300 \207" [file-user-uid] 1] nil t)
 ("GID" #[0 "\300 \207" [file-group-gid] 1] nil t)
 ("PATH"
  (#[0 "\300\301!\302 \303\304#\207"
       [eshell-get-path t path-separator mapconcat identity] 6]
   . #[514 "\300!\210\207" [eshell-set-path] 4
	   ("/nix/store/yvwy8dm26cpa1j12ixgs1dyiaw2abdk9-emacs-snapshot/share/emacs/31.0.50/lisp/eshell/esh-var.elc"
	    . 2966)])
  t t)
 ("_"
  #[514 "\204	�\301!@\207\302#\207"
	[eshell-last-arguments last eshell-apply-indices] 6
	("/nix/store/yvwy8dm26cpa1j12ixgs1dyiaw2abdk9-emacs-snapshot/share/emacs/31.0.50/lisp/eshell/esh-var.elc"
	 . 2986)])
 ("?" (eshell-last-command-status)) ("$" (eshell-last-command-result))
 ("0" eshell-command-name)
 ("1" #[0 "@\207" [eshell-command-arguments] 1] nil t)
 ("2" #[0 "A@\207" [eshell-command-arguments] 1] nil t)
 ("3" #[0 "\3018\207" [eshell-command-arguments 2] 2] nil t)
 ("4" #[0 "\3018\207" [eshell-command-arguments 3] 2] nil t)
 ("5" #[0 "\3018\207" [eshell-command-arguments 4] 2] nil t)
 ("6" #[0 "\3018\207" [eshell-command-arguments 5] 2] nil t)
 ("7" #[0 "\3018\207" [eshell-command-arguments 6] 2] nil t)
 ("8" #[0 "\3018\207" [eshell-command-arguments 7] 2] nil t)
 ("9" #[0 "\3018\207" [eshell-command-arguments 8] 2] nil t)
 ("*" (eshell-command-arguments)))

Documentation

This list provides aliasing for variable references.

Each member is of the following form:

  (NAME VALUE [COPY-TO-ENVIRONMENT] [SIMPLE-FUNCTION])

NAME defines the name of the variable, VALUE is a Lisp value used to compute the string value that will be returned when the variable is accessed via the syntax $NAME.

If VALUE is a cons (GET . SET), then variable references to NAME will use GET to get the value, and SET to set it. GET and SET can be one of the forms described below. If SET is nil, the variable is read-only.

If VALUE is a function, its behavior depends on the value of SIMPLE-FUNCTION. If SIMPLE-FUNCTION is nil, call VALUE with two arguments: the list of the indices that were used in the reference, and either t or nil depending on whether or not the variable was quoted with double quotes. For example, if NAME were aliased to a function, a reference of $NAME[10][20] would result in that function being called with the arguments (("10") ("20")) and nil. If SIMPLE-FUNCTION is non-nil, call the function with no arguments and then pass its return value to eshell-apply-indices.

When VALUE is a function, it's read-only by default. To make it writable, use the (GET . SET) form described above. If SET is a function, it takes two arguments: a list of indices (currently always nil, but reserved for future enhancement), and the new value to set.

If VALUE is a string, get/set the value for the variable with that name in the current environment. When getting the value, if no variable with that name exists in the environment, but if a symbol with that same name exists and has a value bound to it, return that symbol's value instead. You can prefer symbol values over environment values by setting the value of eshell-prefer-lisp-variables to t.

If VALUE is a symbol, get/set the value bound to it.

If VALUE has any other type, signal an error.

Additionally, if COPY-TO-ENVIRONMENT is non-nil, the alias should be copied (a.k.a. "exported") to the environment of created subprocesses.

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

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-var.el.gz
(defcustom eshell-variable-aliases-list
  `(;; for eshell.el
    ("COLUMNS" ,(lambda () (window-body-width nil 'remap)) t t)
    ("LINES" ,(lambda () (window-body-height nil 'remap)) t t)
    ("INSIDE_EMACS" eshell-inside-emacs t)
    ("PAGER" (,(lambda () (or comint-pager (getenv "PAGER")))
              . ,(lambda (_ value)
                   ;; When unsetting PAGER, be sure to clear its value
                   ;; from `process-environment' too.
                   (unless value (setenv "PAGER"))
                   (setq comint-pager value)))
     t t)
    ("UID" ,(lambda () (file-user-uid)) nil t)
    ("GID" ,(lambda () (file-group-gid)) nil t)

    ;; for esh-ext.el
    ("PATH" (,(lambda () (string-join (eshell-get-path t) (path-separator)))
             . ,(lambda (_ value)
                  (eshell-set-path value)
                  value))
     t t)

    ;; for esh-cmd.el
    ("_" ,(lambda (indices quoted)
	    (if (not indices)
                (car (last eshell-last-arguments))
	      (eshell-apply-indices eshell-last-arguments
				    indices quoted))))
    ("?" (eshell-last-command-status . nil))
    ("$" (eshell-last-command-result . nil))

    ;; for em-alias.el and em-script.el
    ("0" eshell-command-name)
    ("1" ,(lambda () (nth 0 eshell-command-arguments)) nil t)
    ("2" ,(lambda () (nth 1 eshell-command-arguments)) nil t)
    ("3" ,(lambda () (nth 2 eshell-command-arguments)) nil t)
    ("4" ,(lambda () (nth 3 eshell-command-arguments)) nil t)
    ("5" ,(lambda () (nth 4 eshell-command-arguments)) nil t)
    ("6" ,(lambda () (nth 5 eshell-command-arguments)) nil t)
    ("7" ,(lambda () (nth 6 eshell-command-arguments)) nil t)
    ("8" ,(lambda () (nth 7 eshell-command-arguments)) nil t)
    ("9" ,(lambda () (nth 8 eshell-command-arguments)) nil t)
    ("*" (eshell-command-arguments . nil)))
  "This list provides aliasing for variable references.
Each member is of the following form:

  (NAME VALUE [COPY-TO-ENVIRONMENT] [SIMPLE-FUNCTION])

NAME defines the name of the variable, VALUE is a Lisp value used to
compute the string value that will be returned when the variable is
accessed via the syntax `$NAME'.

If VALUE is a cons (GET . SET), then variable references to NAME
will use GET to get the value, and SET to set it.  GET and SET
can be one of the forms described below.  If SET is nil, the
variable is read-only.

If VALUE is a function, its behavior depends on the value of
SIMPLE-FUNCTION.  If SIMPLE-FUNCTION is nil, call VALUE with two
arguments: the list of the indices that were used in the reference,
and either t or nil depending on whether or not the variable was
quoted with double quotes.  For example, if `NAME' were aliased
to a function, a reference of `$NAME[10][20]' would result in that
function being called with the arguments `((\"10\") (\"20\"))' and
nil.  If SIMPLE-FUNCTION is non-nil, call the function with no
arguments and then pass its return value to `eshell-apply-indices'.

When VALUE is a function, it's read-only by default.  To make it
writable, use the (GET . SET) form described above.  If SET is a
function, it takes two arguments: a list of indices (currently
always nil, but reserved for future enhancement), and the new
value to set.

If VALUE is a string, get/set the value for the variable with
that name in the current environment.  When getting the value, if
no variable with that name exists in the environment, but if a
symbol with that same name exists and has a value bound to it,
return that symbol's value instead.  You can prefer symbol values
over environment values by setting the value of
`eshell-prefer-lisp-variables' to t.

If VALUE is a symbol, get/set the value bound to it.

If VALUE has any other type, signal an error.

Additionally, if COPY-TO-ENVIRONMENT is non-nil, the alias should be
copied (a.k.a. \"exported\") to the environment of created subprocesses."
  :version "29.1"
  :type '(repeat (list string sexp
		       (choice (const :tag "Copy to environment" t)
                               (const :tag "Use only in Eshell" nil))
                       (choice (const :tag "Call without argument" t)
                               (const :tag "Call with 2 arguments" nil))))
  :risky t)