ghswitch
v1.2.1
Published
Beautiful GitHub Account Switcher - Interactive CLI tool for managing multiple GitHub accounts per repository
Maintainers
Readme
🎯 GhSwitch - Beautiful GitHub Account Switcher
<## 🚀 Quick Start
After installation, usage is simple:
ghswitchThis will launch the interactive menu where you can:
- Add your GitHub accounts (SSH keys and/or tokens)
- Switch between accounts in any repository
- Test connections to verify everything works
- Manage account settings as needed
First Time Setup
- Run
ghswitchin your terminal - Choose "➕ Add account"
- Enter your GitHub account details
- Choose authentication method (SSH or Token)
- Follow the prompts to configure
Switching Accounts
- Navigate to any Git repository
- Run
ghswitch - Choose "🔄 Switch account for current repo"
- Select your desired account
- Done! Your repository now uses the selected account">
✨ A beautiful, interactive CLI tool for seamlessly managing multiple GitHub accounts per repository
📦 Installation
🚀 One-line Install (Recommended)
curl -fsSL https://raw.githubusercontent.com/podsni/GhSwitch/main/install-curl.sh | bash📦 Package Managers
NPM/Yarn/PNPM
npm install -g ghswitch
yarn global add ghswitch
pnpm add -g ghswitchBun (Recommended)
bun install -g ghswitch🐚 Shell Compatibility: Works with bash, zsh, fish, and other POSIX-compatible shells. Automatically detects and uses the best runtime (Bun → Node.js → fallback).
Homebrew (macOS/Linux)
brew tap podsni/ghswitch
brew install ghswitchArch Linux (AUR)
yay -S ghswitch-bin
paru -S ghswitch-binScoop (Windows)
scoop bucket add podsni https://github.com/podsni/scoop-ghswitch
scoop install ghswitch📥 Manual Download
Download pre-built binaries from GitHub Releases:
- Linux x64:
ghswitch - Linux ARM64:
ghswitch-linux-arm64 - Windows x64:
ghswitch.exe - macOS Intel:
ghswitch-macos - macOS Apple Silicon:
ghswitch-macos-arm64
# Make executable and move to PATH
chmod +x ghswitch
sudo mv ghswitch /usr/local/bin/📋 See INSTALL.md for all installation methods and troubleshooting.
📥 Manual Download
Download pre-built binaries from GitHub Releases:
- Linux x64:
ghswitch - Linux ARM64:
ghswitch-linux-arm64 - Windows x64:
ghswitch.exe - macOS Intel:
ghswitch-macos - macOS Apple Silicon:
ghswitch-macos-arm64
# Make executable and move to PATH
chmod +x ghswitch
sudo mv ghswitch /usr/local/bin/📋 See INSTALL.md for all installation methods and troubleshooting.
🌟 Features
- 🎨 Beautiful Terminal UI - Inspired by Charm design principles
- 🔄 Multi-Account Support - Effortlessly switch between different GitHub accounts
- 🔐 Dual Authentication - Support for both SSH keys and Personal Access Tokens
- 📁 Per-Repository Configuration - Different accounts for different repositories
- ⚡ Zero Dependencies - Single executable file, no runtime required
- 🎯 Interactive Interface - Intuitive prompts and visual feedback
- 🔑 SSH Key Management - Generate, import, and manage SSH keys
- 🌈 Colorful Output - Rich colors and gradients for better UX
- 🎯 Active Account Detection - See which account is currently active
- 🖥️ Cross-Platform Support - Full Windows, Linux, macOS compatibility with proper path handling
- Generate SSH key dan Import SSH private key (auto chmod, auto
.pub, auto alias/penamaan berdasarkan username). - Test koneksi: uji SSH alias dan/atau token.
🛠️ Development Setup
Only needed if you want to build from source:
Prasyarat
- Bun v1.0+
- Git
- OpenSSH (
ssh,ssh-keygen) - opsional:
curl(untuk tes token)
Instalasi
# Clone repository
git clone https://github.com/podsni/GhSwitch.git
cd GhSwitch
# Install dependencies
bun installDevelopment
# Run in development mode
bun run index.ts
# or
bun run startBuilding Standalone Executables
# Build for current platform
bun run build
# Build for all platforms
./build.sh
# Individual platform builds
bun run build:linux # Linux x64
bun run build:windows # Windows x64
bun run build:macos # macOS x64 & ARM64Anda akan melihat menu interaktif di terminal.
Konsep Singkat
- Setiap “akun” menyimpan: label,
user.name/user.email(opsional), konfigurasi SSH (key path + host alias), dan/atau konfigurasi Token (username + PAT). - Konfigurasi disimpan di
~/.config/github-switch/config.json. - Untuk SSH, tool akan menulis blok
Hostpada~/.ssh/configseperti contoh:
Host github-<label>
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_<label>
IdentitiesOnly yesAlur Utama
- Tambah Akun (Add account)
- Pilih metode: SSH, Token, atau keduanya.
- Isi
user.name/user.emailjika ingin di-set per repo saat switch. - SSH: pilih dari daftar key yang sudah ada di
~/.ssh(auto-suggestion) atau ketik path manual; bisa generate baru jika belum ada. - Token: isi username + Personal Access Token (PAT).
- Import SSH Private Key (opsional, lebih mudah)
- Pilih menu “Import SSH private key”.
- Masukkan GitHub username → tool otomatis menyarankan nama file tujuan langsung di
~/.ssh, contoh:~/.ssh/id_ed25519_<username>. - Masukkan path private key sumber (mis.
~/.ssh/id_ed25519). - Auto-suggestion: Anda akan mendapat daftar key yang sudah ada di
~/.sshuntuk dipilih, dan juga saran nama file tujuan yang umum dipakai. - Pilih apakah ingin menjadikannya default untuk Host
github.com(disarankan agar mudah ganti-ganti). - Opsional: tambahkan juga alias Host khusus (mis.
github-<username>), jika Anda tetap ingin alias. - Tool akan:
- Menyalin key ke
~/.ssh/<nama-file>dan set permission600. - Membuat public key
<nama-file>.pubbila belum ada (permission644). - Jika dipilih, menulis/menimpa blok
Host github.comagar memakai key ini. - Jika dipilih, menulis blok alias tambahan.
- Opsional langsung tes koneksi SSH (ke
github.comatau alias yang dipilih).
- Menyalin key ke
- Switch Akun untuk Repo Saat Ini
- Jalankan tool di dalam folder repo git.
- Pilih “Switch account for current repo”, pilih akun, lalu pilih metode (SSH/Token).
- Tool akan:
- SSH: set
origin→[email protected]:owner/repo.git, aturuser.name/user.emaillokal repo (Host tetapgithub.com). - Token: set
origin→https://github.com/owner/repo.git, aturcredential.helper storedan tulis~/.git-credentials. - Jika repo belum punya remote, tool akan minta input
owner/repo.
- SSH: set
- Tes Koneksi
- Pilih “Test connection”, pilih akun, lalu pilih metode:
- SSH: jalankan
ssh -T [email protected]dan laporkan hasil. - Token: cek
https://api.github.com/userdengan Basic Auth; sukses bila HTTP 200.
- SSH: jalankan
- Switch SSH Secara Global (tetap Host github.com)
- Pilih “Switch SSH globally (Host github.com)”.
- Pilih akun (harus punya SSH key).
- Tool akan menulis/menimpa blok berikut pada
~/.ssh/config:
Host github.com
HostName github.com
User git
IdentityFile /path/ke/private_key_akun
IdentitiesOnly yes- Dampak: semua akses
[email protected]:owner/repo.gitakan memakai key tersebut (tanpa ganti-ganti alias). Cocok jika ingin satu key aktif secara global dan mudah ditukar. - Anda bisa kapan saja menjalankan menu ini lagi untuk mengganti key global.
- Edit/Hapus/List Akun
- Edit: ubah label,
user.name/user.email, aktif/nonaktif metode, ganti key path/alias atau token. - Remove: hapus akun dari konfigurasi (tidak menghapus blok
Hostotomatis agar aman; bisa dihapus manual bila perlu). - List: tampilkan ringkasan akun yang tersimpan.
Mode SSH (Detail)
- Generate Key: menu “Generate SSH key for an account”. Key dibuat dengan tipe Ed25519, tanpa passphrase (bisa Anda tambah sendiri nanti).
- Import Key: menu “Import SSH private key”.
- Penamaan otomatis berdasarkan GitHub username untuk konsistensi.
- Izin file di-set: private
600, public644. - Alihkan host alias di
~/.ssh/configuntuk memaksa key tertentu saat akses GitHub.
Mode Token (HTTPS)
- Remote di-set ke
https://github.com/owner/repo.git. credential.helper storeakan menulis token ke~/.git-credentialsdalam plaintext.- Catatan keamanan: pertimbangkan pakai SSH bila memungkinkan guna menghindari penyimpanan token plaintext.
Tips & Praktik Terbaik
- Gunakan alias yang konsisten, mis.
github-work,github-personal. - Jika punya beberapa key, pastikan setiap repo diarahkan ke alias yang tepat.
- Untuk token, beri scope minimal yang diperlukan.
🎯 Use Cases
- Personal & Work Accounts: Keep your personal and work GitHub accounts separate
- Multiple Organizations: Switch between different organization accounts
- Client Projects: Use different accounts for different client repositories
- Open Source & Private: Different identities for public and private projects
🔧 Advanced Features
- SSH Key Generation: Generate Ed25519 keys directly from the CLI
- SSH Key Import: Import existing keys with automatic setup
- Global SSH Switching: Change SSH identity globally for all repositories
- Connection Testing: Verify SSH and token connectivity
- Automatic Permissions: Proper file permissions set automatically
- Cross-Platform Paths: Handles Windows, Linux, and macOS path differences
📚 Documentation
- Installation Guide - All installation methods
- Distribution Guide - For package maintainers
- Build Instructions - Building from source
- Release Process - For maintainers
🤝 Contributing
Contributions are welcome! Please check our Contributing Guidelines and feel free to:
- Report bugs by opening an issue
- Request features through discussions
- Submit pull requests with improvements
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with Bun for lightning-fast performance
- UI inspired by Charm design principles
- Thanks to all contributors who help make this tool better
Made with ❤️ by podsni
⭐ If you find GhSwitch useful, please give it a star on GitHub!
