xks is a CLI tool for switching between multiple Git profiles,
seamlessly managing both .gitconfig and SSH keys. It allows you to save,
apply, and delete profiles while ensuring that only the necessary files are
modified.
- Save and switch between multiple Git profiles.
- Automatically updates
.gitconfigand SSH keys. - Ensures that only default Git and SSH files are managed.
- Lightweight, with just one external Rust dependency (
sha2).
You can install xks in three different ways:
To install automatically, run one of the following commands:
With curl:
curl -fsSL https://xks.rwx222.com/install.sh | shOr with wget:
wget -qO- https://xks.rwx222.com/install.sh | shImportant
If you get a "No write permission" error during installation, try adding sudo before sh (the install command):
curl -fsSL https://xks.rwx222.com/install.sh | sudo shOr:
wget -qO- https://xks.rwx222.com/install.sh | sudo shImportant
On macOS, after installation and the first time you run xks, you might need to manually allow the binary to run by going to:
System Settings > Privacy & Security
Visit GitHub Releases and download the appropriate archive for your OS and architecture.
Then, extract the xks binary and move it to a directory in your $PATH,
such as:
tar -xzf xks-<version>-<os>-<arch>.tar.gz -C /usr/local/bin/If you prefer to build xks yourself, you can compile it with Rust:
cargo build --release
cp target/release/xks /usr/local/bin/Or move it to any directory included in your $PATH.
xks manages only the default Git and SSH configuration files (current_files):
~/.gitconfig
~/.ssh/config
~/.ssh/id_ed25519 (also id_ed25519.pub)
~/.ssh/id_ecdsa (also id_ecdsa.pub)
~/.ssh/id_rsa (also id_rsa.pub)
~/.ssh/id_dsa (also id_dsa.pub)
All data is stored in ~/.xks. Custom SSH keys or additional Git configuration
files are ignored.
xks <command> [options]xksList 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 discardDelete the current_files.xks versionShow the version number.xks helpShow usage information.
-ySkip confirmation prompts.
xks # List saved profiles and current_files state
xks save work # Save current_files as 'work' profile
xks use personal # Switch to 'personal' profile
xks use - # Switch back to the previous profile
xks remove alex # Delete 'alex' profile
xks discard # Delete current_filesxks is released under the MIT License.
I created xks because I often need to switch between different Git profiles
for work and personal projects.
Since SSH keys cannot be shared between multiple accounts, managing them manually quickly became frustrating. While there are existing tools and other techniques to solve this problem, I wanted to build my own as a way to learn Rust.
Although xks was originally designed for Git profiles, it can be useful in
different scenarios:
- Switching between Git profiles, with or without SSH keys.
- Managing SSH keys independently, even without Git, for accessing multiple remote servers.
- Handling both Git profiles and SSH keys together, making it easy to manage multiple identities.
This allows you to:
- Switch between SSH keys for different remote servers.
- Separate work and personal Git profiles.
- Manage multiple Git accounts for freelance clients.
- Use different Git configurations per profile.
If you find yourself in a similar situation, give xks a try! 🚀
