If you've ever been in a situation where your company requires you to use a different GitHub account from your personal one (or GitLab, Bitbucket, etc
), with a corporate email.
Or if you need to use different SSH keys to access various remote servers.
Then you've likely faced the tedious task of manually managing multiple accounts or profiles on the same computer, with different SSH keys and/or different Git configurations in your .gitconfig
file.
There are both simple and advanced ways to handle this with special Git and SSH configurations, but honestly, I just wanted a quick and simple way to switch between profiles without overcomplicating things.
That's why I created xks
.
What is xks?
xks
is a CLI written in Rust to switch SSH keys and/or Git profiles with a single command.
It works without extra configurations, using (and only considering
) the default files in Unix systems (Linux & macOS
):
Git File
~/.gitconfig
SSH Files
~/.ssh/config
~/.ssh/id_ed25519
~/.ssh/id_ed25519.pub
~/.ssh/id_ecdsa
~/.ssh/id_ecdsa.pub
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
~/.ssh/id_dsa
~/.ssh/id_dsa.pub
(Only the files that exist when saving a profile; any other custom-named SSH keys are ignored).
π οΈ How Does It Work?
xks
stores backups of your .gitconfig
file and SSH keys
in their current state inside the local ~/.xks
directory as a profile.
You can then modify/delete the current files, save them as another profile, and safely switch between profiles without worrying about losing configurations.
π¦ Installation
You can install it in seconds with curl
:
curl -fsSL https://xks.rwx222.com/install.sh | sh
Or if you prefer wget
:
wget -qO- https://xks.rwx222.com/install.sh | sh
Or, if you prefer, you can check out the code and compile it yourself with Rust.
Then run:
xks help
π₯ Commands
-
xks
List saved profiles and current files state. -
xks save <profile>
Save the current files as a profile. -
xks use <profile>
Apply a saved profile. -
xks use -
Switch back to the previously used profile. -
xks remove <profile>
Delete a saved profile β οΈ. -
xks discard
Delete the current files β οΈ.
π€ Why Not Use Another Tool?
As I mentioned, I know there are other ways to handle this situation. But they all require extra manual configurations.
xks
simply switches everything with one command and leaves it as if you had never changed anything.
π Try It and Let Me Know What You Think
If you have feedback, improvements, or find a bug, PRs are welcome.
Top comments (0)