blueyi/my-utils

Some useful script for config linux system

Shell

3

283 commits

updated Sep 23, 2026

See the code

README

My-Utils

One-click dev environment setup for Linux / macOS. Default shells: bash + zsh (Oh My Zsh); Fish is optional (see below). Also vimrc, tmux, etc.

Features

  • Linux (Ubuntu / Debian / Fedora) and macOS
  • Configs managed via symlinks; edits stay in repo for backup and version control
  • One-shot or selective install; --yes for non-interactive mode; --force to re-run / reinstall
  • macOS: declarative common/Brewfile + optional common/Brewfile.optional; --new-mac for new-machine checks
  • Mainland China mirrors (Go / Node / uv / npm / Cargo) via config/mirrors.bash + linked ~/.npmrc / ~/.cargo/config.toml
  • Profile presets: C++, Python, AI Infra (LLVM / MLIR); optional Triton (GPU kernel) via config/triton.bash
  • One env file: config/resetrc.bash holds all shared env as # SECTION: … blocks (nvm, pyenv, CUDA, LLVM, …). Edit that file to affect bash, zsh, and profiles; optional Fish uses the same file via emit_fish_env.bash when linked.

Design: multi-OS, multi-shell, minimal host changes

What touches the system

  • Only $HOME (and standard XDG paths) are modified by default, via common/link.inicreate_links.sh: symlinks such as ~/.bashrc, ~/.zshrc, ~/.my-utils.env, ~/.shell_init.bash, etc. Fish symlinks are commented out in link.ini until you opt in.
  • Shell env logic lives entirely under the cloned repo (config/resetrc.bash, shell_init.bash, …). No /etc patches are required for this dotfiles layout.
  • common/misc.sh may run chsh to zsh after Oh My Zsh install—that does change the login shell in /etc/passwd (or equivalent). Remove or guard that block if you want zero account-level changes.

Multi-OS

Multi-shell

Gaps (by choice)

  • Login-only sessions that never source ~/.bashrc / ~/.zshrc won’t load my-utils unless you add a one-liner to ~/.profile or ~/.zprofile pointing at shell_init / resetrc—not linked by default to keep the installer conservative.

中文概要: 默认 packages 只装 zsh(含 Oh My Zsh 相关),不装 FishFish 相关 symlink 在 link.ini 里默认注释,需用时自行安装 fish 并取消注释后再跑 linksmiscchsh 可能把登录 shell 改为 zsh。

Quick Start

git clone https://github.com/blueyi/my-utils.git ~/workspace/my-utils
cd ~/workspace/my-utils

./myu help                    # unified CLI (short for my-utils)

# One-shot init (no prompts): packages, links, misc, vimrc, cursor
./myu setup --yes
# same as: ./bootstrap.sh --yes

exec $SHELL

New Mac

# 1) Xcode CLT (if needed)
xcode-select --install

# 2) Sign in to the Mac App Store (required for Brewfile `mas` entries)

# 3) Clone and bootstrap
git clone https://github.com/blueyi/my-utils.git ~/workspace/my-utils
cd ~/workspace/my-utils
./myu setup --new-mac --yes

# Optional extra apps (discord, lark, Telegram, …):
./myu packages --optional --yes

# Privacy vault (prompt for password ≥8 chars; decrypt privacy/*.enc):
# ./myu vault restore

# Re-run is safe: successful tools and already-installed packages are skipped.
# Force a full redo:
./myu setup --new-mac --force --yes

exec $SHELL

Edit common/Brewfile for the core macOS set; put extras in common/Brewfile.optional. Changing either file (when used) invalidates the packages stamp. Changing common/link.ini invalidates the links stamp so new symlinks (e.g. npmrc / cargo) apply on the next --yes.

Mainland China mirrors

Default on after links + shell init:

Disable env mirrors: export MY_UTILS_MIRRORS=off in ~/.env.rc. Unlink the two files to fully revert npm/Cargo registries.

Install Options

Preferred entry: ./myu (short for my-utils). bootstrap.sh still works as the underlying runner.

./myu help

./myu setup --yes                             # packages links misc vimrc cursor
./myu packages --yes
./myu packages --optional --yes
./myu links --force --yes
./myu vault backup                            # encrypt → privacy/*.enc
./myu vault restore                           # decrypt (password prompt, ≥8 chars)
./myu setup --new-mac --yes                   # includes vault restore

# Equivalent low-level:
./bootstrap.sh --tools env --yes
./bootstrap.sh --tools vault-backup --yes

Idempotency: successful tools write stamps under ~/.local/state/my-utils/bootstrap/. Later runs skip those tools unless --force. packages also re-runs when Brewfile (+ optional, if used) changes; links re-runs when link.ini changes. Within packages, already-installed apt/yum/brew packages are skipped unless --force (then reinstall).

Config Layout

~/.vimrc, ~/.bashrc, ~/.zshrc symlink to files under config/. ~/.p10k.zshconfig/p10k.zsh (Powerlevel10k; edit in repo, re-run links if needed). ~/.bashrc / ~/.zshrc end with source ~/.shell_init.bash, which runs config/shell_init.bash: zsh → Oh My Zsh + p10k + resetrc.bash; bash → interactive defaults + resetrc.bash. All shared env lives in config/resetrc.bash as ordered # SECTION: … blocks (proxy, PATH, nvm, pyenv, zsh-only OpenClaw/fzf, CUDA, LLVM, …). Zsh-only bits are guarded with ZSH_VERSION inside that file.

config/
├── _vimrc, _bashrc, _zshrc   → ~/.vimrc, ~/.bashrc, ~/.zshrc
├── p10k.zsh                  → ~/.p10k.zsh (Powerlevel10k theme)
├── shell_init.bash           → ~/.shell_init.bash
├── resetrc.bash              # monolithic env (comment sections; search SECTION:)
├── mirrors.bash              # Mainland China env mirrors (GOPROXY, NODEJS_ORG_MIRROR, …)
├── npm/npmrc                 → ~/.npmrc
├── cargo/config.toml         → ~/.cargo/config.toml
├── zprofile.brew.bash        # reference snippet; misc appends brew shellenv to ~/.zprofile
├── sections/README.md        # pointer only (old split layout archived in deprecated/)
├── bash_interactive.bash     # bash-only prompt, completion
├── zsh_entry.zsh             # Oh My Zsh + theme/plugins, then resetrc
├── path.bash, cmake_env.bash # thin → resetrc (IDE one-liners)
├── emit_fish_env.bash, fish/my-utils.fish  # optional Fish; symlink via commented lines in link.ini
├── triton.bash               # optional GPU/Triton layer on top of resetrc
├── deprecated/               # archive (see deprecated/README.md)
└── ...

Optional Fish

Not installed or linked by default. Steps: sudo apt install fish (or brew install fish) → uncomment the two Fish lines in common/link.ini./bootstrap.sh --tools links --yes. Then Fish loads my-utils.fish, which runs emit_fish_env.bash to mirror resetrc.bash + optional_home.bash exports. For pyenv in Fish, see pyenv init - fish upstream.

Profiles and optional env

# Preset profiles (manual source)
source ~/repos/my-utils/profiles/cpp/env.bash      # C++ / LLVM
source ~/repos/my-utils/profiles/python/env.bash   # Python
source ~/repos/my-utils/profiles/ai_infra/env.bash  # AI Infra

# Triton (GPU kernel) dev
source "$MYRC_PATH/triton.bash"

Troubleshooting

CMake: Ninja / C/C++ compiler not found

If you see:

  • CMake was unable to find a build program corresponding to "Ninja"
  • CMAKE_C_COMPILER not set / CMAKE_CXX_COMPILER not set

Quick fix (any terminal, including Cursor/IDE): source the CMake env script before running cmake so PATH, CC, CXX, and CMAKE_MAKE_PROGRAM are set:

# Replace with your actual my-utils path if different
source ~/workspace/my-utils/config/cmake_env.bash
# or, if MY_UTILS_ROOT is already set:
source "$MY_UTILS_ROOT/config/cmake_env.bash"

cd /path/to/your/project/build
cmake ..

macOS:

  1. PATH: Homebrew and baseline paths are set in config/resetrc.bash when you use the linked rc. If your terminal didn’t load it (e.g. Cursor’s built-in terminal), use the source .../config/cmake_env.bash one-liner above (it sources resetrc.bash).

  2. C/C++ compiler: Install Xcode Command Line Tools so clang is available:

    xcode-select --install
    

Linux (apt): Install packages with ./bootstrap.sh --tools packages --yes. If the terminal didn’t load your rc, run source .../config/cmake_env.bash before cmake.

Git dual-remote (gdr)

Interactive git is always the real git (never wrapped). Dual-remote lives only in gdr.

When GitHub is slow/blocked and you keep a GitCode mirror under the same namespace (blueyi/…):

git pull -r                 # native git
gdr pull -r                 # dual: pull origin; on timeout → gitcode
gdr push                    # push GitHub then GitCode (OK if either succeeds)
gdr fetch origin
gdr clone git@github.com:blueyi/foo.git
gdr setup                   # wire origin + gitcode remotes for current repo
gdr setup --scan ~/workspace/repos

gdr lives at common/gdr (MY_BIN / common/ is on PATH after shell init). Defaults: config/git-dual-remote.env.

Privacy vault (encrypted secrets in git)

Password-encrypt machine-local secrets into privacy/*.enc, commit ciphertext to GitHub, and restore on a new machine after clone.

CommandPurpose
./myu vault backupEncrypt paths in privacy/manifest
./myu vault restoreDecrypt into $HOME (prompts if SYNC_ENV_KEY unset)
./myu vault encrypt -i SRC -o DST.encEncrypt one file
./myu vault decrypt -i SRC.enc [-o DST]Decrypt one file (stdout if -o omitted)
./myu setup --new-macBootstrap + restore at the end
# Old machine (batch)
./myu vault backup
git add privacy/*.enc privacy/manifest && git commit -m "Update privacy vault" && git push

# Single file
./myu vault encrypt -i ~/.ssh/config -o privacy/ssh-config.enc
./myu vault decrypt -i privacy/ssh-config.enc -o ~/.ssh/config

# New machine
./myu vault restore

Password: SYNC_ENV_KEY or interactive prompt, ≥8 characters. Crypto: OpenSSL AES-256-CBC + PBKDF2. Edit privacy/manifest (name|mode|path). Modes: file, env-merge.

Cursor Config Backup

Sync Cursor settings to cursor_bak/ and use symlinks so edits stay in the repo. Backed up (macOS: ~/Library/Application Support/Cursor, Linux: ~/.config/Cursor):

  • User/ – settings.json, keybindings.json, mcp.json, snippets, etc.
  • Preferences – app-level preferences file
  • ide_state.json – when present
  • ~/.cursor/rulescursor_bak/rules
  • ~/.cursor/projectscursor_bak/projects (per-workspace state; terminals/, agent-transcripts/, mcps/ schema caches, and canvases/{node_modules,tsconfig.json} are gitignored — user MCP config is in User/mcp.json)

Included in default tool list (both ./bootstrap.sh --yes and interactive ./bootstrap.sh will include cursor unless you use --tools to limit):

./bootstrap.sh --yes                    # runs cursor step with others
./bootstrap.sh --tools cursor --yes     # only Cursor config link
./bootstrap.sh --tools cursor          # interactive: ask then link
# Standalone:
./common/cursor_config_link.sh          # Link
./common/cursor_config_link.sh --restore   # Restore original paths

License

MIT

Contributors

blueyi

283 commits

blueyi/my-utils

Some useful script for config linux system

Shell

3

283 commits

updated Sep 23, 2026

See the code

README

My-Utils

One-click dev environment setup for Linux / macOS. Default shells: bash + zsh (Oh My Zsh); Fish is optional (see below). Also vimrc, tmux, etc.

Features

  • Linux (Ubuntu / Debian / Fedora) and macOS
  • Configs managed via symlinks; edits stay in repo for backup and version control
  • One-shot or selective install; --yes for non-interactive mode; --force to re-run / reinstall
  • macOS: declarative common/Brewfile + optional common/Brewfile.optional; --new-mac for new-machine checks
  • Mainland China mirrors (Go / Node / uv / npm / Cargo) via config/mirrors.bash + linked ~/.npmrc / ~/.cargo/config.toml
  • Profile presets: C++, Python, AI Infra (LLVM / MLIR); optional Triton (GPU kernel) via config/triton.bash
  • One env file: config/resetrc.bash holds all shared env as # SECTION: … blocks (nvm, pyenv, CUDA, LLVM, …). Edit that file to affect bash, zsh, and profiles; optional Fish uses the same file via emit_fish_env.bash when linked.

Design: multi-OS, multi-shell, minimal host changes

What touches the system

  • Only $HOME (and standard XDG paths) are modified by default, via common/link.inicreate_links.sh: symlinks such as ~/.bashrc, ~/.zshrc, ~/.my-utils.env, ~/.shell_init.bash, etc. Fish symlinks are commented out in link.ini until you opt in.
  • Shell env logic lives entirely under the cloned repo (config/resetrc.bash, shell_init.bash, …). No /etc patches are required for this dotfiles layout.
  • common/misc.sh may run chsh to zsh after Oh My Zsh install—that does change the login shell in /etc/passwd (or equivalent). Remove or guard that block if you want zero account-level changes.

Multi-OS

Multi-shell

Gaps (by choice)

  • Login-only sessions that never source ~/.bashrc / ~/.zshrc won’t load my-utils unless you add a one-liner to ~/.profile or ~/.zprofile pointing at shell_init / resetrc—not linked by default to keep the installer conservative.

中文概要: 默认 packages 只装 zsh(含 Oh My Zsh 相关),不装 FishFish 相关 symlink 在 link.ini 里默认注释,需用时自行安装 fish 并取消注释后再跑 linksmiscchsh 可能把登录 shell 改为 zsh。

Quick Start

git clone https://github.com/blueyi/my-utils.git ~/workspace/my-utils
cd ~/workspace/my-utils

./myu help                    # unified CLI (short for my-utils)

# One-shot init (no prompts): packages, links, misc, vimrc, cursor
./myu setup --yes
# same as: ./bootstrap.sh --yes

exec $SHELL

New Mac

# 1) Xcode CLT (if needed)
xcode-select --install

# 2) Sign in to the Mac App Store (required for Brewfile `mas` entries)

# 3) Clone and bootstrap
git clone https://github.com/blueyi/my-utils.git ~/workspace/my-utils
cd ~/workspace/my-utils
./myu setup --new-mac --yes

# Optional extra apps (discord, lark, Telegram, …):
./myu packages --optional --yes

# Privacy vault (prompt for password ≥8 chars; decrypt privacy/*.enc):
# ./myu vault restore

# Re-run is safe: successful tools and already-installed packages are skipped.
# Force a full redo:
./myu setup --new-mac --force --yes

exec $SHELL

Edit common/Brewfile for the core macOS set; put extras in common/Brewfile.optional. Changing either file (when used) invalidates the packages stamp. Changing common/link.ini invalidates the links stamp so new symlinks (e.g. npmrc / cargo) apply on the next --yes.

Mainland China mirrors

Default on after links + shell init:

Disable env mirrors: export MY_UTILS_MIRRORS=off in ~/.env.rc. Unlink the two files to fully revert npm/Cargo registries.

Install Options

Preferred entry: ./myu (short for my-utils). bootstrap.sh still works as the underlying runner.

./myu help

./myu setup --yes                             # packages links misc vimrc cursor
./myu packages --yes
./myu packages --optional --yes
./myu links --force --yes
./myu vault backup                            # encrypt → privacy/*.enc
./myu vault restore                           # decrypt (password prompt, ≥8 chars)
./myu setup --new-mac --yes                   # includes vault restore

# Equivalent low-level:
./bootstrap.sh --tools env --yes
./bootstrap.sh --tools vault-backup --yes

Idempotency: successful tools write stamps under ~/.local/state/my-utils/bootstrap/. Later runs skip those tools unless --force. packages also re-runs when Brewfile (+ optional, if used) changes; links re-runs when link.ini changes. Within packages, already-installed apt/yum/brew packages are skipped unless --force (then reinstall).

Config Layout

~/.vimrc, ~/.bashrc, ~/.zshrc symlink to files under config/. ~/.p10k.zshconfig/p10k.zsh (Powerlevel10k; edit in repo, re-run links if needed). ~/.bashrc / ~/.zshrc end with source ~/.shell_init.bash, which runs config/shell_init.bash: zsh → Oh My Zsh + p10k + resetrc.bash; bash → interactive defaults + resetrc.bash. All shared env lives in config/resetrc.bash as ordered # SECTION: … blocks (proxy, PATH, nvm, pyenv, zsh-only OpenClaw/fzf, CUDA, LLVM, …). Zsh-only bits are guarded with ZSH_VERSION inside that file.

config/
├── _vimrc, _bashrc, _zshrc   → ~/.vimrc, ~/.bashrc, ~/.zshrc
├── p10k.zsh                  → ~/.p10k.zsh (Powerlevel10k theme)
├── shell_init.bash           → ~/.shell_init.bash
├── resetrc.bash              # monolithic env (comment sections; search SECTION:)
├── mirrors.bash              # Mainland China env mirrors (GOPROXY, NODEJS_ORG_MIRROR, …)
├── npm/npmrc                 → ~/.npmrc
├── cargo/config.toml         → ~/.cargo/config.toml
├── zprofile.brew.bash        # reference snippet; misc appends brew shellenv to ~/.zprofile
├── sections/README.md        # pointer only (old split layout archived in deprecated/)
├── bash_interactive.bash     # bash-only prompt, completion
├── zsh_entry.zsh             # Oh My Zsh + theme/plugins, then resetrc
├── path.bash, cmake_env.bash # thin → resetrc (IDE one-liners)
├── emit_fish_env.bash, fish/my-utils.fish  # optional Fish; symlink via commented lines in link.ini
├── triton.bash               # optional GPU/Triton layer on top of resetrc
├── deprecated/               # archive (see deprecated/README.md)
└── ...

Optional Fish

Not installed or linked by default. Steps: sudo apt install fish (or brew install fish) → uncomment the two Fish lines in common/link.ini./bootstrap.sh --tools links --yes. Then Fish loads my-utils.fish, which runs emit_fish_env.bash to mirror resetrc.bash + optional_home.bash exports. For pyenv in Fish, see pyenv init - fish upstream.

Profiles and optional env

# Preset profiles (manual source)
source ~/repos/my-utils/profiles/cpp/env.bash      # C++ / LLVM
source ~/repos/my-utils/profiles/python/env.bash   # Python
source ~/repos/my-utils/profiles/ai_infra/env.bash  # AI Infra

# Triton (GPU kernel) dev
source "$MYRC_PATH/triton.bash"

Troubleshooting

CMake: Ninja / C/C++ compiler not found

If you see:

  • CMake was unable to find a build program corresponding to "Ninja"
  • CMAKE_C_COMPILER not set / CMAKE_CXX_COMPILER not set

Quick fix (any terminal, including Cursor/IDE): source the CMake env script before running cmake so PATH, CC, CXX, and CMAKE_MAKE_PROGRAM are set:

# Replace with your actual my-utils path if different
source ~/workspace/my-utils/config/cmake_env.bash
# or, if MY_UTILS_ROOT is already set:
source "$MY_UTILS_ROOT/config/cmake_env.bash"

cd /path/to/your/project/build
cmake ..

macOS:

  1. PATH: Homebrew and baseline paths are set in config/resetrc.bash when you use the linked rc. If your terminal didn’t load it (e.g. Cursor’s built-in terminal), use the source .../config/cmake_env.bash one-liner above (it sources resetrc.bash).

  2. C/C++ compiler: Install Xcode Command Line Tools so clang is available:

    xcode-select --install
    

Linux (apt): Install packages with ./bootstrap.sh --tools packages --yes. If the terminal didn’t load your rc, run source .../config/cmake_env.bash before cmake.

Git dual-remote (gdr)

Interactive git is always the real git (never wrapped). Dual-remote lives only in gdr.

When GitHub is slow/blocked and you keep a GitCode mirror under the same namespace (blueyi/…):

git pull -r                 # native git
gdr pull -r                 # dual: pull origin; on timeout → gitcode
gdr push                    # push GitHub then GitCode (OK if either succeeds)
gdr fetch origin
gdr clone git@github.com:blueyi/foo.git
gdr setup                   # wire origin + gitcode remotes for current repo
gdr setup --scan ~/workspace/repos

gdr lives at common/gdr (MY_BIN / common/ is on PATH after shell init). Defaults: config/git-dual-remote.env.

Privacy vault (encrypted secrets in git)

Password-encrypt machine-local secrets into privacy/*.enc, commit ciphertext to GitHub, and restore on a new machine after clone.

CommandPurpose
./myu vault backupEncrypt paths in privacy/manifest
./myu vault restoreDecrypt into $HOME (prompts if SYNC_ENV_KEY unset)
./myu vault encrypt -i SRC -o DST.encEncrypt one file
./myu vault decrypt -i SRC.enc [-o DST]Decrypt one file (stdout if -o omitted)
./myu setup --new-macBootstrap + restore at the end
# Old machine (batch)
./myu vault backup
git add privacy/*.enc privacy/manifest && git commit -m "Update privacy vault" && git push

# Single file
./myu vault encrypt -i ~/.ssh/config -o privacy/ssh-config.enc
./myu vault decrypt -i privacy/ssh-config.enc -o ~/.ssh/config

# New machine
./myu vault restore

Password: SYNC_ENV_KEY or interactive prompt, ≥8 characters. Crypto: OpenSSL AES-256-CBC + PBKDF2. Edit privacy/manifest (name|mode|path). Modes: file, env-merge.

Cursor Config Backup

Sync Cursor settings to cursor_bak/ and use symlinks so edits stay in the repo. Backed up (macOS: ~/Library/Application Support/Cursor, Linux: ~/.config/Cursor):

  • User/ – settings.json, keybindings.json, mcp.json, snippets, etc.
  • Preferences – app-level preferences file
  • ide_state.json – when present
  • ~/.cursor/rulescursor_bak/rules
  • ~/.cursor/projectscursor_bak/projects (per-workspace state; terminals/, agent-transcripts/, mcps/ schema caches, and canvases/{node_modules,tsconfig.json} are gitignored — user MCP config is in User/mcp.json)

Included in default tool list (both ./bootstrap.sh --yes and interactive ./bootstrap.sh will include cursor unless you use --tools to limit):

./bootstrap.sh --yes                    # runs cursor step with others
./bootstrap.sh --tools cursor --yes     # only Cursor config link
./bootstrap.sh --tools cursor          # interactive: ask then link
# Standalone:
./common/cursor_config_link.sh          # Link
./common/cursor_config_link.sh --restore   # Restore original paths

License

MIT

Contributors

blueyi

283 commits

Languages

Shell

72.2%

Python

8.1%

Vim Script

7.3%

TypeScript

4.8%

JavaScript

4.1%

CSS

2.5%