Identities
An identity groups a git author, an SSH key, and a set of credential entries. Switching identity switches all of them at once.
identities: - id: personal git_user: Your Name email: you@example.com ssh_key: ~/.ssh/id_ed25519 default: true activates: npm_token: personal gh_token: personal
- id: work git_user: Your Name email: you@company.example ssh_key: ~/.ssh/work_ed25519 activates: npm_token: work gh_token: workSwitching
Section titled “Switching”loadout identity list # what is configured, and which is activeloadout identity activate workOr the shipped s function, which is the same thing with less typing:
s workSwitching does three things: sets your git author for subsequent commits, adds the identity’s SSH key to the agent, and makes each credential entry named in activates the active one.
What switching does not do
Section titled “What switching does not do”It does not change shells you already have open. Credential values were exported into those shells when they started; changing which entry is active updates the configuration, not the processes already running.
Re-run the eval in any shell that needs the new values:
eval "$(loadout env)"Or use the flag that prints them for you:
loadout identity activate work --exportwhich emits the export lines for the new entries alongside the switch, ready to be evaluated.
It does not rewrite the generated shell file. Identity is runtime state, not something baked into init.zsh, so there is no need to run loadout apply after switching.
The activates map
Section titled “The activates map”Keys are credential names, values are entry names. Both must exist:
activates: npm_token: work # npm_token must be declared, with an entry called workAn identity may nominate any subset. Credentials not named are left on whatever entry they were on, which is usually what you want for a token that is not account-specific.
Previewing another identity
Section titled “Previewing another identity”loadout env --identity workPrints the export lines as they would be after switching, without switching. Useful in a script that needs work credentials for one command without disturbing your session.
Git author and SSH key
Section titled “Git author and SSH key”The git author is applied with git config, scoped globally by default. If you would rather scope per repository, do not use identity switching for it — set user.email in the repository and git will prefer it.
The SSH key is added with ssh-add, which reaches the agent over $SSH_AUTH_SOCK and therefore works from a child process. That is why s could have been a subcommand of the binary rather than a shell function; it stays a function only for consistency with the rest of the catalog.