Profiles#
tgs supports multiple Telegram accounts through profiles — similar to how AWS CLI handles credentials. Each profile has its own independent session stored in a separate database file.
How Profile Resolution Works#
When you run any tgs command, the active profile is determined by this priority chain (highest wins):
--profileflag passed to the commandTGS_PROFILEenvironment variable.tgs.yamlfile in the current directory or any parent directory"default"(fallback)
Per-Directory Profiles#
You can bind a profile to a directory by creating a .tgs.yaml file. Use tgs profile switch to do this automatically:
cd ~/projects/work-project
tgs profile switch workprofile: worktgs walks up the directory tree to find .tgs.yaml, so it applies in all subdirectories too. This is the recommended way to use different accounts per project.
Managing Profiles#
List profiles#
tgs profile list* default (@myuser)
work (@workuser)The * marks the currently active profile. JSON output is the default and includes an active field.
Switch profile for current directory#
tgs profile switch workThis creates or overwrites .tgs.yaml in the current directory.
Delete a profile#
tgs profile delete old-accounttgs profile switch default
tgs profile delete workDeletes the profile directory and its session database. You cannot delete the currently active profile — switch to another profile first.
Check current profile and account#
tgs whoami
tgs whoami --output textProfile: work
User: John Doe (id: 123456789)
Handle: @johndoe
Phone: +1234567890whoami reads from local storage — it does not connect to Telegram.
Environment Variable#
Set TGS_PROFILE to override the profile for a single command or for the whole shell session:
# One-off override
TGS_PROFILE=work tgs whoami
# Override for the shell session
export TGS_PROFILE=workThe --profile flag always takes precedence over TGS_PROFILE.
Practical Examples#
tgs --profile work search "design review"mkdir ~/projects/client-x && cd ~/projects/client-x
tgs login --type code --profile client-x
tgs profile switch client-xtgs whoami --output textFull Reference#
- tgs profile — list, switch, delete subcommands
- tgs whoami — show current account info
- Environment Variables — all supported env vars