【Tool Recommendation】【神器级】One-Click Source Switching chsrc for All Platforms

Use Case

Changing brew source on macOS used to require many commands (previously needed many commands), now it’s done with one line

❯ chsrc set brew
[chsrc Speed Test] Testing speed

  x Upstream default source Upstream default source URL unknown, please help to supplement
  - Tsinghua University Open Source Mirror ... 4.89 MByte/s
  - Beijing Foreign Studies University Open Source Mirror ... 5.60 MByte/s
  - Zhejiang University Open Source Mirror ... 125.95 KByte/s
  - Southern University of Science and Technology Open Source Mirror ... 5.39 MByte/s

Fastest mirror site: Beijing Foreign Studies University Open Source Mirror
Selected mirror site: BFSU (bfsu)
--------------------------------
[chsrc Backup] ~/.zshrc -> ~/.zshrc.bak
[chsrc Write] ~/.zshrc
[chsrc Backup] ~/.bashrc -> ~/.bashrc.bak
[chsrc Write] ~/.bashrc
[chsrc Backup] ~/.config/fish/config.fish -> ~/.config/fish/config.fish.bak
[chsrc Write] ~/.config/fish/config.fish
--------------------------------
chsrc: Fully automated source change completed, thanks to mirror provider: Beijing Foreign Studies University Open Source Mirror
[chsrc Notice] Please restart the terminal to make the Homebrew environment variables take effect

Official Introduction

Universal cross-platform source-switching tool and framework chsrc, aiming to support as many OS environments as possible including Linux, Windows (MSYS2, Cygwin), macOS, BSD, as well as as many CPUs as possible such as Loongson, Phytium, RISC-V.

We use C99 to achieve this goal. We do not use interpreted languages like Python or JS, because a simple source-switching tool should not forcibly impose a huge interpreter and dozens or hundreds of MBs of other files on users.

Automatic speed testing, find the fastest, switch source

    $ chsrc set ruby

If you don’t want automatic speed testing, you can use the fastest mirror tested by the maintenance team

    $ chsrc set ruby first

List available mirrors first, then select one, e.g., use RubyChina as mirror

    $ chsrc ls  ruby
    $ chsrc set ruby rubychina

If you have your own mirror URL, use a custom URL

    $ chsrc set ruby https://gems.ruby-china.com/

For targets supporting *project-level* source switching, you can avoid global (*system-level* or *user-level*) source switching

    $ chsrc set -local bundler
    $ chsrc set -local pdm

Official Source Code