EnvSwitch
A fast, reliable command-line tool for managing and switching environment variable configurations. Built with Rust for performance and safety.
Features
- 🚀 Fast Configuration Switching: Instantly switch between different environment variable sets
- 🐚 Multi-Shell Support: Works with zsh, fish, bash, and other shells
- 💾 Persistent Storage: Configurations are saved locally and persist across sessions
- 🔒 Safe Operations: Built-in validation prevents invalid configurations
- 📦 Import/Export: Share configurations between machines or backup your settings
- 🎯 Claude AI Integration: Optimized for switching between different AI model configurations
Installation
From Source
Using Cargo
Quick Start
1. Create your first configuration
# Create a configuration for DeepSeek AI
# Create a configuration for Kimi AI
2. Switch between configurations
# Switch to DeepSeek configuration
# Switch to Kimi configuration
3. View your configurations
# List all configurations
# Show current active configuration and environment variables
Shell Integration
For the best experience, add these aliases to your shell configuration:
Zsh (~/.zshrc)
Fish (~/.config/fish/config.fish)
alias switch-deepseek='eval (envswitch use deepseek)'
alias switch-kimi='eval (envswitch use kimi)'
alias envs='envswitch list'
alias envstatus='envswitch status'
Bash (~/.bashrc)
Commands
Configuration Management
# Create or update a configuration
# List all configurations
# Show detailed information about a configuration
# Delete a configuration
# Edit a configuration interactively
Environment Switching
# Switch to a configuration (generates shell commands)
# Show current environment status
# Clear environment variables
Import/Export
# Export all configurations to JSON (default format)
# Export with metadata and pretty formatting
# Export specific configurations
# Export in different formats
# Import configurations from a file
# Import with backup (creates backup before importing)
# Import with conflict resolution
# Preview import without making changes
# Import from different formats (auto-detected)
Configuration Examples
AI Model Configurations
# OpenAI GPT-4
# Anthropic Claude
# Local development
# Production
Advanced Usage
Conditional Configurations
# Create configurations with descriptions
Backup and Restore
# Create a backup of all configurations
# Restore from backup with merge
# Force restore (overwrites existing configurations)
# Preview what would be restored
Interactive Configuration Editing
# Edit a configuration interactively
# The interactive editor allows you to:
# - Add new environment variables
# - Edit existing variables
# - Delete variables
# - Update configuration description
# - Save or cancel changes
Advanced Export/Import Options
# Export with verbose output
# Export only specific configurations with metadata
# Import with validation and backup
# Cross-format conversion (export JSON, import as ENV)
Configuration File Location
Configurations are stored in:
- macOS/Linux:
~/.config/envswitch/config.json - Windows:
%APPDATA%\envswitch\config.json
Troubleshooting
Common Issues
Configuration not found
# If you see suggestions, check for typos in the configuration name
Shell commands not working
# Make sure to use eval
# Check your shell type
# For fish shell, use different syntax
)
Permission errors
# Check configuration directory permissions
# Fix permissions if needed
Import/Export issues
# Check file format and content
# Use verbose mode for detailed error information
# For corrupted files, check the format
Interactive editing problems
# If edit command doesn't work, check configuration exists
# Create new configuration if needed
Large configuration performance
# For large configurations, use specific exports
# Use non-pretty format for faster processing
Getting Help
# Show help for all commands
# Show help for a specific command
Development
Building from Source
Running Tests
# Run all tests
# Run specific test suites
# Run tests with output
# Run specific test
Project Structure
src/
├── main.rs # Main entry point
├── cli.rs # Command line interface
├── config.rs # Configuration management
├── env.rs # Environment variable handling
├── shell.rs # Shell detection and command generation
├── error.rs # Error types and handling
├── types.rs # Common type definitions
├── commands/ # Command implementations
├── handlers/ # Utility handlers
└── utils/ # Utility functions
tests/
├── integration_tests.rs # End-to-end workflow tests
├── shell_compatibility_tests.rs # Shell-specific tests
└── error_scenario_tests.rs # Error handling tests
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Ensure all tests pass (
cargo test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.