[开源] SwitchEnvs 一个管理、切换多个环境变量方案的工具

查看 6|回复 0
作者:junjian2016   
SwitchEnvs 是一个管理、切换多个环境变量方案的工具,可视化对本机环境变量进行增删改查。(类似于 SwitchHosts )
Github 地址:
https://github.com/dean2021/SwitchEnvs
README 如下:
SwitchEnvs
A desktop environment variable management tool built with Wails (Go + React/TypeScript). SwitchEnvs allows you to manage, save, and switch between multiple environment variable configurations with ease.
Screenshot

Features
  • Multiple Environment Schemes: Create, edit, duplicate, and delete environment variable schemes
  • One-Click Switch: Quickly switch between different environment configurations
  • Persistent Storage: Schemes are saved locally and persist across sessions
  • Shell Integration: Automatically updates your shell environment (~/.switch_env)
  • Import/Export: Share your environment schemes with others
  • Custom Window: macOS-style frameless window with transparent background and rounded corners
  • Auto-Reload: Changes to the currently applied scheme are immediately reflected

    Tech Stack
  • Backend: Go with Wails v2
  • Frontend: React 18 + TypeScript + Tailwind CSS
  • Runtime: Native desktop application

    Getting Started
    Prerequisites
  • Go 1.23+
  • Node.js & npm
  • Wails CLI

    Installation
    # Install Wails CLI if not already installed
    go install github.com/wailsapp/wails/v2/cmd/wails@latest
    # Clone and setup
    git clone https://github.com/dean2021/SwitchEnvs.git
    cd SwitchEnvs
    # Install frontend dependencies
    cd frontend && npm install
    # Return to project root
    cd ..
    Development
    Run the application in development mode with hot reload:
    wails dev
    This will start both the Go backend and the React frontend with automatic rebuilding.
    Building
    Build the production version:
    wails build
    Build for specific platforms:
    # macOS ARM64
    wails build -platform darwin/arm64
    # Windows AMD64
    wails build -platform windows/amd64
    # Linux
    wails build -platform linux/amd64
    Usage
    Creating a Scheme
    [ol]
  • Click "Add Scheme" to create a new environment scheme
  • Add key-value pairs for your environment variables
  • Click "Apply" to activate the scheme
    [/ol]
    Switching Schemes
  • Select a scheme from the sidebar
  • Click "Apply" to switch to that environment configuration

    Exporting/Importing
  • Use the export button to save your schemes as JSON
  • Use the import button to load schemes from a JSON file

    File Structure
    SwitchEnvs/
    ├── app.go              # Main application logic (Go)
    ├── main.go             # Application entry point
    ├── wails.json          # Wails configuration
    ├── frontend/           # React frontend
    │   ├── src/
    │   │   ├── App.tsx     # Main React component
    │   │   ├── main.tsx    # React entry point
    │   │   ├── style.css   # Global styles
    │   │   └── types/      # TypeScript type definitions
    │   ├── package.json
    │   └── vite.config.ts
    └── build/              # Build configurations
    Data Storage
    [td]Path[/td]
    [td]Purpose[/td]
    ~/.switchenvs/schemes.json
    All saved schemes in JSON format
    ~/.switchenvs/applied_scheme.json
    Persisted applied scheme name
    ~/.switch_env
    Shell script with export KEY="value" entries
    Architecture
    Backend (Go)
    The Go backend handles:
  • Scheme CRUD operations (Save, Get, Delete, Duplicate)
  • Applying schemes to the system
  • Writing environment variables to shell config
  • Import/Export functionality

    Frontend (React + TypeScript)
    The frontend provides:
  • Interactive UI for managing environment schemes
  • Real-time updates when switching schemes
  • Import/Export dialogs
  • Custom window controls (minimize, close)

    Shell Integration
    SwitchEnvs writes environment variables to ~/.switch_env and automatically adds a source command to ~/.zshrc. To use the environment variables in your terminal:
    source ~/.switch_env
    Or restart your terminal session.
    License
    MIT License
  • 您需要登录后才可以回帖 登录 | 立即注册

    返回顶部