Skip to content

Latest commit

 

History

History
372 lines (290 loc) · 19.8 KB

README_CN.md

File metadata and controls

372 lines (290 loc) · 19.8 KB

Oxidizer

CI license code size repo size

一个简单 & 可扩展的,用于统一终端操作的 dotfile 管理工具

English | 简体中文

oxidizer

1. 从这里开始

对 macOS / Linux(Intel)

export OXIDIZER=$HOME/oxidizer
git clone --depth=1 https://github.com/ivaquero/oxidizer.git $OXIDIZER && bash $OXIDIZER/install.sh
  • 对中国大陆用户,可设置 BREW_CN 变量来下载安装 Homebrew:
export BREW_CN=1

对 Windows

$env:OXIDIZER = "$HOME\oxidizer"
git clone --depth=1 https://github.com/ivaquero/oxidizer.git $env:OXIDIZER; . $env:OXIDIZER\install.ps1

对于 Cmder 用户,你需要删除%CMDER_ROOT%\vendor\profile.ps1的最后一行Set-Item -Path function:\prompt -Value $Prompt -Options ReadOnly中的-Options ReadOnly

安装之后,您可以在custom.sh中个性化您的系统环境(请参考defaults.sh,通过一下命令打开

edf ox

可使用 upox 命令来更新 Oxidizer

2. Oxidizer 的主要目标

Oxidizer 起初主要为非管理员用户设计,用于快速搭建跨平台统一的工作环境,避免重复和繁琐的环境配置劳动,其具有特点

  • 跨平台(主要基于 Rust 工具链)
  • 最少依赖 & 最少安装
  • 可扩展架构
  • 统一接口 & 丝滑操作
  • 超级快!(载入时间 < 1 秒)

2.1. CLI 工具替换

☑️ 表示默认安装

  • coreutils
  • non-coreutils
    • 使用 dust 替换 du
    • 使用 fd 替换 find
    • 使用 ripgrep 替换 grep
    • 使用 sd 替换 sed
    • 使用 tlrc 替换 tldrman
    • 使用 zoxide 替换 cdz
    • 使用 hyperfine 替换 time
    • 使用 procs 替换 ps
    • 使用 starship 替换 powerline10kohmyposh
    • 使用 tokei 替换 cloc
    • 使用 tre 替换 tree

Nushell 是一个 Rust 编写的全平台 Shell,但其目前不支持动态地址,而且其插件只支持 Rust 和 Python,而不是其内置的 Nu 语言。

2.2. TUI 工具替换

  • 使用 bottom 替换 tophtop
  • 使用 gitui 替换 lazygit
  • 使用 yazi 替换 range
  • 使用 helix 替换 vim (非平替)
  • 使用 zellij 替换 tmux(目前不支持 Windows)

2.3. GUI 工具替换

更推荐 WezTerm,自带分屏器

2.4. 其他实用的 Rust 工具

  • ouch:终端无痛压缩 & 解压工具
  • pueue:命令行并行任务管理器
  • kondo:项目依赖清理命令行工具
  • navi:交互式 cheatsheet 命令行
  • onefetch:命令行 Git 信息工具

2.5. 插件总结

插件位于 oxplugins

OxPlugins-PowerShell 已停止维护。

插件缩写 类别 macOS 自动加载?
oxpbg 推荐 Git
oxpom 系统快捷操作 macOS
oxpod 系统快捷操作 Debian-Based Systems
oxpor 系统快捷操作 RedHat-Based Systems
oxpow 系统快捷操作 Windows(包括 winget)
oxppb 包管理器 Homebrew(macOS & Linux)
oxpps 包管理器 Scoop(Windows)
oxppc 包管理器 Conda(多语言,主要是 Python)
oxppcn 包管理器 Conan(C++)
oxppn 包管理器 NPM(JavaScript)
oxpptl 包管理器 tlmgr(TeXLive)
oxpljl 编程语言 Julia
oxplrb 编程语言 Ruby(包括 gem)
oxplrs 编程语言 Rust(包括 cargo, rustup)
oxpsc 服务 Container(Docker & Podman)
oxpsp 服务 Pueue
oxpcbw 软件的命令行界面 Bitwarden
oxpces 软件的命令行界面 Espanso
oxpcjr 软件的命令行界面 Jupyter(notebook, lab, book)
oxpcvs 软件的命令行界面 VSCode
oxpuf 系统工具 文件操作
oxpufm 系统工具 格式转换
oxpunw 系统工具 网络配置
oxptwr 终端工具 天气(基于 wttr)
oxptzj 终端工具 Zellij(macOS & Linux)
oxpxns 其他 笔记备份(Obsidian & Logseq)

将对应的缩写放入 ~/oxidizer/custom.shOX_PLUGINS 即可加载插件

OX_PLUGINS=(
oxpbg
oxpufm
oxplrs
)

Oxidizer 通过 HomebrewScoop 管理包和软件,以绕过管理员权限的要求。

3. 文件管理

design

  • rff
    • 通过 source 刷新
  • edf
    • 通过 $EDITOR 编辑(默认:VSCode)
  • brf
    • 通过 bat/cat 浏览文件
    • 文件夹:通过 lsd/ls 浏览
  • rdf (reduce file)
    • 还原文件:在 $OX_OXIDE 中覆盖对应的 $OX_ELEMENT 文件配置
  • oxf (oxidize file)
    • 氧化文件:在 $OX_ELEMENT 中覆盖对应的 $OX_OXIDE 文件配置
  • clzf (catalyze file)
    • 催化文件:在 $OX_OXYGEN 中覆盖对应的 $OX_ELEMENT 文件配置
  • ppgf (propagate file)
    • 传播文件:在 $OX_OXYGEN 中覆盖对应的 $OX_OXIDE 文件配置

例如,当你想编辑 ~/.zshrc,键入 edf zs

当你使用 oxf zs~/.zshrc 会被复制并保存到 $OX_BACKUP/shell 文件夹。其中,$OX_BACKUP 是可以在 $OXIDIZER/custom.sh 中自定义的备份路径。通过 edf ox 即可轻松打开 custom.sh 文件。

下表罗列了每个配置文件的缩写:

来源 代号 对应文件 定义扩展
oxidizer ox custom.sh
zsh zs .zshrc built-in
starship ss starship.toml built-in
wezterm wz wezterm.lua custom.sh
debian sc /etc/apt/sources.list oxpod
winget w winget.json oxpow
git gi .gitignore oxpbg
git g .gitconfig oxpbg
conda c .condarc oxppc
conan cn conan.conf oxppcn
conan cnr remotes.json oxppcn
conan cnd profiles/default oxppcn
javascript jsx js-pkgs.txt oxppn
npm n .npmrc oxppn
latex tl texlive-pkgs oxpptl
julia jl startup.jl oxpljl
julia jlx julia-pkgs.txt oxpljl
julia jlp Project.toml oxpljl
julia jlm Manifest.toml oxpljl
cargo cg config.toml oxlrs
rustup rs settings.toml oxlrs
espanso es default.yml oxpces
espanso esb match/base.yml oxpces
espanso esx_ match/packages oxpces
vscode vs settings.json oxpcvs
vscode vsk keybindings.json oxpcvs
vscode vss_ snippets oxpcvs
vscode vsx vscode-pkgs.txt oxpcvs
jupyter jr jupyter_notebook_config.py oxpcjr
pueue pu pueue.yml oxpsp
pueue pua pueue_aliases.yml oxpsp
zellij zj config.kdl oxptzj
zellij zjl_ layouts oxptzj

_ 表示文件夹,你可以详细查看每个相关文件缩写 these abbreviations closely by brf [Plugin Abbr.] or edf [Plugin Abbr.].

Oxidizer 使用 ouch 压缩或解压缩文件,提供 3 个快捷命令

  • zpf:压缩
  • uzpf:解压缩
  • lzpf:显示压缩文件中的内容

4. 软件管理

  • back_*
    • 文件:将配置文件保存至自定义文件夹 $OX_BACKUP
  • up_*
    • 文件:根据自定义文件夹 $OX_BACKUP 中的配置文件安装
  • clean_*
    • 文件:根据自定义文件夹 $OX_BACKUP 中的配置文件清理

back_*up_* 适用于 brewscoopcondavscodeespansojuliatlmgrnpmclean_* 适用于 brewconda

5. 包管理

Oxidizer 致力于为各个包管理器提供统一的接口,以减轻敲击和记忆负担。

后缀 操作 brew b scoop s conda c npm n cargo cg rustup rs julia jl gem rb conan cn tlmgr tl
*h help
*cf config
*is install
*us uninstall
*up update
*ups update self
*ls list
*lv leaves
*sc search
*cl clean
*if info
*st status
*ck check
*pn pin
*upn unpin
*dp depends
*rdp needs
*xa add repo
*xrm remove repo
*xls list repo

特别地,Oxidizer 提供两组后缀为p的实验性函数,用于并行安装和下载软件包

  • brew:bisp, biscp, bupp
  • scoop:sisp, supp

例如,当需要安装 2 个及以上的包时,可以使用 bisp [pkg1] [pkg1] 代替 bis [pkg1] [pkg1],进行并行下载安装。

同理,biscp, bupp 分别为 bisc, bup 的并行版本。

使用并行功能前,需要启动 pueue 服务

# All OS
pueued -d
# or macOS / Linux
bss pu

一些包管理器还有项目管理功能

后缀 操作 brew b scoop s conda c npm n cargo cg rustup rs julia jl gem rb conan cn
*ii init/create
*b build
*r run
*ed edit
*ct cat
*ln link
*ts test
*au audit
*fx fix
*pb publish

部分快捷命令被包含在对应的系统扩展中

  • ox-macos oxpm:自启动,包含 mas
  • ox-debians oxpd:自启动,包含 apt
  • ox-windows oxpw:自启动,包含 wingetwsl·
后缀 对应操作 mas m apt a flatpak f winget w wsl wl
*h help
*is install
*us uninstall
*up update
*ups update self
*ls list
*lv leaves
*sc search
*cl clean
*if info
*st status
*ck check
*dp depends

5.1. Homebrew 管理

  • bris:brew reinstall 重装
  • bup:brew upgrade 更新

前缀 c 是一个标志用来严格限制 brew 命令只针对的 casks 操作

  • bisc:安装 cask

  • brisc:重装 cask

  • bupc:升级 cask

  • bupg:brew upgrade --greedy

  • brp:适用于下载文件替换缓存中的 brew cask

    • $1:cask name
  • bmr:using brew mirror 使用 brew 镜像

  • bmrq:reset brew git source to official repositories 重置 brew 到官方源

5.2. Conda 环境管理

请注意,Conda 插件基于 mambaconda-tree 包,需要预先安装

conda install -c conda-forge mamba conda-tree

除了上面包管理提及的 Conda 命令,Conda 插件还提供了 Conda 环境管理的快捷命令,均以 ce 开头

  • cerat: 重启环境,类似 ceat
  • ceq: 退出环境(q 代表 kill/quit
  • cecr: 创建环境
  • cerm: 删除环境,类似 ceat 但不删除 base 环境
  • cels: 环境包列表
  • cedf: 对比环境
  • cern: 重命名环境
  • cesd: 改变架构 conda-forge subdir
    • i: 对 osx-64linux-64win-64
    • a: 对 osx-arm64linux-aarch64 huo win-arm64
    • p: 对 ppc64le
    • s: 对 linux-s390x
  • ceep: 导出环境

6. 项目管理

6.1. Git

  • gclhs:删除提交历史

7. 更多阅读

8. 致谢

9. 许可

这个项目在 GPL-v3 许可下发布