Skip to content

zhangzhenxiang666/env-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Environment Variable Manager (env-manage)

中文文档

A Rust-based CLI tool for managing your shell environment variables. It allows you to switch between different profiles and handles dependencies automatically. It also provides a TUI (Terminal User Interface) for visual management.

em -h  # Show help information

Help Information

This tool uses the TOML format to store environment variable configurations. Profiles are stored in the ~/.config/env-manage/profiles directory by default.

  • global.toml: A special profile located at ~/.config/env-manage/global.toml that is automatically loaded every time the terminal starts.

Each profile consists of two parts:

  • variables: A list of key-value pairs representing the environment variables to be set.
  • profiles: A list of other profiles that the current profile depends on.

Example configuration:

profiles = []

[variables]
https_proxy = "http://172.26.240.1:7890"
all_proxy = "http://172.26.240.1:7890"
http_proxy = "http://172.26.240.1:7890"

Features

  • Profile Management: Create and organize environment variables into different profiles.
  • Dependency Resolution: Handle complex dependencies between profiles.
  • TUI Interface: Terminal user interface for intuitive configuration management.
  • Shell Integration: Support for Bash, Zsh, Fish, and PowerShell.

Installation

Automated installation scripts are available for the following shells. These scripts will download the latest binary and configure your shell environment.

Bash

curl -fsSL https://raw.githubusercontent.com/zhangzhenxiang666/env-manager/main/scripts/install_bash.sh | bash

Zsh

curl -fsSL https://raw.githubusercontent.com/zhangzhenxiang666/env-manager/main/scripts/install_zsh.sh | bash

Fish

curl -fsSL https://raw.githubusercontent.com/zhangzhenxiang666/env-manager/main/scripts/install_fish.sh | bash

PowerShell (Windows)

irm https://raw.githubusercontent.com/zhangzhenxiang666/env-manager/main/scripts/install_powershell.ps1 | iex

Manual Installation

If you prefer to install manually:

  1. Download the binary from the Releases page.

  2. Place it in a directory of your choice. Note: You do not need to add this directory to your system PATH.

  3. Add the initialization command to your shell configuration file. Replace /path/to/env-manage with the actual path to your binary.

    • Bash (~/.bashrc):

      eval "$(/path/to/env-manage init bash)"
    • Zsh (~/.zshrc):

      eval "$(/path/to/env-manage init zsh)"
    • Fish (~/.config/fish/config.fish):

      /path/to/env-manage init fish | source
    • PowerShell ($PROFILE):

      Invoke-Expression (& "C:\path\to\env-manage.exe" init powershell | Out-String)

Note: After installation, please restart your terminal or run source ~/.bashrc (or the equivalent config file) to load the configuration.

Usage

TUI Management Interface

Run the following command to start the TUI:

em ui

TUI

Common Commands

  • Temporarily Load Environment Variables:

    Load specified profiles or set variables directly in the current session.

    em use <profile_name or key=value>...
    # Aliases: em activate

    Example: em use profile1 profile2 http_proxy=http://172.26.240.1:7890

  • Unload Environment Variables:

    Remove specified profiles or variables from the current session.

    em unuse <profile_name or key>...
    # Aliases: em deactivate, em drop

    Example: em unuse profile1 profile2 http_proxy

  • Check Status:

    Check the current environment status and consistency.

    em check
  • Fix Consistency Issues:

    Attempt to fix inconsistencies in the environment variable configuration.

    em fix

Configuration

By default, profiles are stored in the ~/.config/env-manage/profiles directory.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors