Files
omarchycn/bin/omarchy-cn-setup
T

74 lines
2.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# omarchy:summary=First-run wizard: locale, fonts, IME, hotkey, mirrors, AI
# omarchy:examples=omarchycn setup
set -euo pipefail
if [[ ! -t 0 ]]; then
echo "omarchycn setup 需要交互终端" >&2
exit 1
fi
STATE_DIR="$HOME/.local/state/omarchycn/setup-done"
mkdir -p "$STATE_DIR"
run_step() {
local step="$1" title="$2"
shift 2
if [[ -f $STATE_DIR/$step ]]; then
gum confirm "「$title」已完成,重新运行?" --default=false || return 0
fi
echo "==> $title"
if "$@"; then
touch "$STATE_DIR/$step"
else
gum confirm "「$title」失败,继续后面的步骤?" || exit 1
fi
}
step_hotkey() {
local choice
choice=$(gum choose --header "输入法切换键" "ctrl-space" "super-space")
omarchy-cn-ime-hotkey "$choice"
}
step_mirror() {
local choice
choice=$(gum choose --header "pacman 镜像策略" "china" "official")
omarchy-cn-mirror-apply "$choice"
}
step_dev_mirror() {
local choice
choice=$(gum choose --header "开发工具镜像(npm/pip/cargo/go/gem" "china" "official" "skip")
if [[ $choice == "skip" ]]; then
return 0
fi
omarchy-cn-dev-mirror-apply "$choice" --target npm,pip,cargo,go,gem
}
step_apps() {
local picks
picks=$(omarchy-cn-app-list | tail -n +2 | awk '{print $1}' |
gum choose --no-limit --header "选择要安装的国内应用(空格多选,回车跳过)" || true)
local app
for app in $picks; do
omarchy-cn-app-install "$app"
done
}
run_step locale "中文 Locale 生成" omarchy-cn-locale-apply
run_step fonts "中文字体与 fallback" omarchy-cn-font-apply
run_step ime "Fcitx5 + Rime 输入法" omarchy-cn-ime-apply
run_step hotkey "输入法切换键" step_hotkey
run_step mirror "pacman 镜像" step_mirror
run_step dev-mirror "开发工具镜像" step_dev_mirror
run_step apps "国内应用" step_apps
run_step ai "AI HubHarness/Provider/Key" omarchy-cn-ai-setup
echo
echo "==> 最终检查"
omarchy-cn-doctor all || true
echo "OmarchyCN 初始化完成。随时可用 omarchycn setup 重进任一步骤。"