Search notes:

Environment variables

Accessing/reading environment variables

Java
In Java, environment variables can be read with System.getenv().
Python
import os
print(os.environ['VAR'])
Perl
print $ENV{VAR};
PowerShell: the so called PowerShell allows to access an environment variable with the special $env:… provider/drive: The following prints a user's home directory:
PS> echo $env:userprofile
Environment variables can also be queried and set from PowerShell with the .NET class System.Environment.
R
Sys.getenv(varname)
The Renviron file.
PHP:
getenv('xyz');
VBA
msgBox environ("TEMP")
Node.js:
process.env.ENVVAR
Oracle: dbms_system.get_env
See also Showing environment variables with Windows Script Host.
In the Windows registry, environment variables are stored for a user under HKEY_CURRENT_USER/Environment and globally under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment.

APPDATA

CD

Windows: the current working directory.

EDITOR

Specifies the prefered editor.
See also VISUAL

GIT_COMMON_DIR

$GIT_COMMON_DIR

GMT_GRIDDIR

sa: General Mapping Tools

GMT_SHAREDIR

sa: General Mapping Tools

GMT_USERDIR

Defaults to ~/.gmt.
sa: General Mapping Tools

HISTCONTROL

See bash history.

HISTIGNORE

See bash history.

HOME

Points to the home directory of a user.
Typically, the value starts with /home/ (Unix, that is).
The Windows equivalent seems to be USERPROFILE
sa: LOGNAME

HTTP_PROXY

See also proxy

LANG

The default locale for categories where neither LC_ALL nor the specific variable for that category is set.

LC_ALL

Localization of programs. It makes their message follow the conventions of a specified country.
The values POSIX and C are equivalent.
sa: LANG

LC_COLLATE

Collation (which influences string sorting).

LC_CTYPE

locale for character sets and character classification.

LC_MESSAGES

Determines the locale to be used for internationalised messages.

LC_MONETARY

locale for formatting monetary values

LC_MONETARY

locale for formatting numbers

LC_TIME

locale for formatting date/time values

LD_LIBRARY_PATH

Specify directories where shared libraries are installed.
See also creating a shared and static library with gcc.

LOGNAME

The name with which a user
sa: HOME

NLSPATH

Determines the location where catopen looks for internationalisation message catalogues.

PATH

A series of directories used to search executable files. The directories are separated with : in Unix and with ; in Windows.

PATHEXT

Gone PATHEXT

PS1

Configure the prompt for a shell.

POSIXLY_CORRECT

If set, blocks are units of 512 bytes, otherwise of 1024 bytes.
See also POSIX

PROMPT_DIRTRIM

R_HOME

Points to the home directory of R.

SECONDS

A bash (only bash?) variable.
t0=$SECONDS

do_stuff

echo $(($SECONDS - $t0)) seconds used for stuff

SHELL

The default shell that useradd assumes when not invoked with the -s flag.

SYSTEMPROFILE

TODO: the ProfileImagePath value in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-18.

SYSTEMROOT

Windows. Typical value: c:\windows.

TERM

VT100, VT220, …

TZ

Time zone in POSIX systems.
In POSIX.1 systems the value of the TZ variable can be in one of three formats:
See also Linux timezone, https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html#TZ-Variable, the influence of $TZ on the date shell command.

USERPROFILE

Seems to be the Windows equivalent of HOME.
See also %USERPROFILE%

VISUAL

See also EDITOR

XDG_CONFIG_DIRS

XDG

XDG_CONFIG_HOME

XDG

XDG_DATA_HOME

XDG

XDG_DATA_DIRS

XDG

XDG_CACHE_HOME

XDG
See also /var/cache

See also

Windows environment variables
R environment variables
~/.ssh/environment

Index