Skip to content

Environment Variables Reference

When Anvil runs an OS command, it sets various environment variables for the command. These can be useful when writing scripts to integrate with Anvil.

The following environment variables are set:

Variable Semantics
ANVIL_WIN_LOCAL_PATH The path of the file being edited in the window where the command was executed. This path does not include the hostname (if the command was being executed remotely).
ANVIL_WIN_GLOBAL_PATH The path of the file being edited in the window where the command was executed including the hostname in the ssh format (i.e. HOST:PATH)
ANVIL_WIN_LOCAL_DIR The parent directory of the file being edited in the window where the command was executed, or the file itself if it is a directory. This path does not include the hostname (if the command was being executed remotely).
ANVIL_WIN_GLOBAL_DIR The parent directory of the file being edited in the window where the command was executed, or the file itself if it is a directory. This includes the hostname in the ssh format (i.e. HOST:PATH)
ANVIL_WIN_ID The internal numeric ID of the window. This may be used in the API.
ANVIL_API_PORT The TCP port number on which the Anvil REST API is running. Connections to the API should be performed to the local host; if a remote command is executed an SSH tunnel is created so that commands may connect locally.
ANVIL_API_SESS Session id used to authenticate the client program against the API.