CLI for managing multiple GitHub accounts. Automatically switches gh auth and git author based on org rules.
- gh (GitHub CLI) with multiple accounts logged in
go install github.com/nurazon59/ghmux@latest~/.config/ghmux/config.yaml
defaults:
profile: personal
profiles:
work:
gh_user: work-login
git:
name: Work Name
email: work@company.com
personal:
gh_user: personal-login
git:
name: Personal Name
email: me@gmail.com
rules:
- hostname: github.com
org: my-company
profile: workRules are evaluated top-down. First match wins. Unmatched orgs fall back to defaults.profile.
Switch gh auth based on the current directory's git remote. Useful as a chpwd hook.
cd ~/src/github.com/my-company/api
ghmux sync
# → gh auth switch --user work-loginGenerate per-profile gitconfig files and includeIf blocks in ~/.gitconfig.
ghmux init
# → generates ~/.gitconfig-work, ~/.gitconfig-personal
# → inserts includeIf block into ~/.gitconfigThis ensures git commit uses the correct author without any wrapper — matching by remote URL via hasconfig:remote.*.url.
Run ghmux sync automatically on every cd by adding a shell hook.
Add to ~/.zshrc:
autoload -U add-zsh-hook
_ghmux_chpwd() { ghmux sync 2>/dev/null }
add-zsh-hook chpwd _ghmux_chpwdCreate ~/.config/fish/conf.d/ghmux.fish:
function _ghmux_cd --on-variable PWD
ghmux sync 2>/dev/null
endMIT