Environment Variables#

All tgs environment variables are optional. They override compiled-in defaults or configuration file values.

Variables#

VariableDescription
TGS_PROFILEActive profile name. Overrides .tgs.yaml but is overridden by --profile flag.
TGS_API_IDTelegram API ID. Overrides the value compiled into the binary.
TGS_API_HASHTelegram API Hash. Overrides the value compiled into the binary.
TGS_CONFIG_DIRConfig directory. Takes precedence over XDG_CONFIG_HOME. Default: $XDG_CONFIG_HOME/tgs, falling back to ~/.config/tgs.
TGS_DATA_DIRData directory for session databases. Takes precedence over XDG_DATA_HOME. Default: $XDG_DATA_HOME/tgs, falling back to ~/.local/share/tgs.
XDG_CONFIG_HOMEBase config directory (XDG spec). Used as $XDG_CONFIG_HOME/tgs when TGS_CONFIG_DIR is unset.
XDG_DATA_HOMEBase data directory (XDG spec). Used as $XDG_DATA_HOME/tgs when TGS_DATA_DIR is unset.

Profile Selection#

# Use the "work" profile for one command
TGS_PROFILE=work tgs whoami

# Use the "work" profile for the whole shell session
export TGS_PROFILE=work

See Profile resolution order for the full priority chain.

API Credentials#

tgs ships with API credentials compiled in. Most users do not need to set these. You may want to override them if you are building tgs from source without credentials, or if you want to use your own Telegram application credentials.

export TGS_API_ID=12345
export TGS_API_HASH=abcdef1234567890abcdef1234567890
tgs login

Obtain API credentials at my.telegram.org.

Custom Directories#

# Store config in a non-default location
export TGS_CONFIG_DIR=/etc/tgs

# Store sessions on a different volume
export TGS_DATA_DIR=/mnt/secure/tgs-data