Compare commits

...

8 Commits
v0.1.0 ... main

5 changed files with 197 additions and 17 deletions

View File

@ -5,19 +5,33 @@
# 默认分支 # 默认分支
BRANCH="dev" BRANCH="dev"
# 是否直接初始化配置仓库
# INIT=""
# 检查是否安装git
if ! command -v git >/dev/null 2>&1; then
echo "git命令未找到请安装git"
exit 1
else
echo "git命令已安装继续执行"
git config --global credential.helper store
fi
# 使用getopts处理参数 # 使用getopts处理参数
while getopts ":hb:" opt; do while getopts ":hib:" opt; do
case $opt in case $opt in
b) BRANCH="$OPTARG" ;; b) BRANCH="$OPTARG" ;;
i) INIT="enable" ;;
h) h)
echo "使用方法: $0 [-d] [-h]" echo "使用方法: $0 [-b <branch>] [-ih]"
echo " -d 开发模式" # echo " -d 开发模式"
echo " -h 显示帮助" echo " -i 初始化配置仓库"
echo " -b 指定分支,默认分支为 dev"
echo " -h 显示帮助, 并退出. 建议放最后一个参数."
exit 0 exit 0
;; ;;
\?) \?)
echo "无效选项: -$OPTARG" >&2 echo "无效选项: -$opt $OPTARG" >&2
exit 1 exit 1
;; ;;
esac esac
@ -29,17 +43,22 @@ test -f "$HOME"/.config/.bin/.Runtime/SELF_MARK_AS_INSTALLED_FROM_SCRIPT && {
echo "local.env.ini already exists, end the install. please remove it first if need re-install." echo "local.env.ini already exists, end the install. please remove it first if need re-install."
exit 1 exit 1
} }
# == 移走原有配置目录 # == 移走原有配置目录~/.config到/tmp/.config
[ -d "/tmp/.config" ] && rm -rf /tmp/.config # 如果存在, 删除 /tmp/.config [ -d "/tmp/.config" ] && rm -rf /tmp/.config # 如果存在, 删除 /tmp/.config
[ -d "$HOME/.config" ] && mv "$HOME/.config" /tmp/.config # 移动原有 $HOME/.config 配置到 /tmp/.config [ -d "$HOME/.config" ] && mv "$HOME/.config" /tmp/.config # 移动原有 $HOME/.config 配置到 /tmp/.config
# 克隆,如果失败则退出 # 克隆,如果失败则退出并恢复原有配置
git clone --depth 1 --branch "$BRANCH" --single-branch https://gitea.yever.top/Hawkin/.config.git "$HOME"/.config git clone --depth 1 --branch "$BRANCH" --single-branch https://gitea.yever.top/Hawkin/.config.git "$HOME"/.config
test $? -ne 0 && { test $? -ne 0 && {
echo "git clone failed, please check your network." echo -e "\033[031mgit clone failed, please check your network.\033[0m"
# 恢复原有配置 # 删除克隆的目录,恢复原有配置
echo -e "\033[034mdelete the unfinished clone dir: $HOME/.config"
[ -d "$HOME/.config" ] && rm -rf "$HOME/.config" [ -d "$HOME/.config" ] && rm -rf "$HOME/.config"
if test -d /tmp/.config; then
echo -e "\033[034mrestoring the old config to $HOME/.config.\033[0m"
mv /tmp/.config "$HOME/.config" mv /tmp/.config "$HOME/.config"
echo "restored the old config to $HOME/.config" else
echo -e "\033[032mno old config found, skip restore config dir..\033[0m"
fi
exit 1 exit 1
} }
@ -50,7 +69,8 @@ cat >"$HOME"/.config/.bin/.Runtime/SELF_MARK_AS_INSTALLED_FROM_SCRIPT <<EOF
如果你想要重新安装, 请删除此文件——下次安装时会将当前配置仓库移动到备份目录(默认为~/.local/share/Origin_Config_Backup. 如果你想要重新安装, 请删除此文件——下次安装时会将当前配置仓库移动到备份目录(默认为~/.local/share/Origin_Config_Backup.
EOF EOF
echo "git clone success, init project by script itself..."
# = 通过目标仓库的初始化脚本进行初始化 # = 通过目标仓库的初始化脚本进行初始化
if test "$INIT" = "enable"; then
echo -e "\033[032mgit clone success, init project by script itself...\033[0m"
bash "$HOME"/.config/.bin/bin/Init.sh bash "$HOME"/.config/.bin/bin/Init.sh
fi

96
osx.bash Normal file
View File

@ -0,0 +1,96 @@
#!/bin/bash
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 一键初始化
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# = 系统优化
#> 视频资源:
# == 设置
# === 锁屏不断网
# 系统设置--电池--选项--将「硬盘」和「网络」改为“永不”
# 系统设置--显示器--高级--「……防止休眠」勾选
# === 允许任意来源的app然后可“设置>隐私与安全性>仍然允许”
sudo spctl --master-disable
# = finder
# == 设置>边栏
# = 终端
# == 默认
# 设置>描述文件>键盘>option作为meta键
# 设置>描述文件>文本>字体 -> JetBrainsMono Nerd Font
# = brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
source "$HOME"/.config/zsh/share/app/brew.sh
# = stats
# https://mac-stats.com/
# https://github.com/exelban/stats/releases/download/v2.11.43/Stats.dmg
# = 安装JetBrainsMono Nerd Font
brew install --cask font-jetbrains-mono-nerd-font
# = python
# == uv
brew install uv
# === uv apps: tidevice
uv python install
# == pyenv
# = nodejs
# == nvm
# 执行`zimfw install`后nvm会自动安装
# == volta
# == corepack enable
# == pnpm
# = 飞书客户端,官网
# = arc 浏览器,要立刻同步
# == arc 插件沉浸式翻译、Vimium C、bitwarden、AutoJump、BiliScope、Virtual Json Viewer、思源(SiYuan)、篡改猴
# = 远程配置仓库
# = bash
# = zsh
cd "$HOME"
ln .config/zsh/zshrc.zsh .zshrc
brew install romkatv/powerlevel10k/powerlevel10k
zimfw install || zimfw reinstall
# = apifox
# = ai chat tool
# == chat box
# https://chatboxai.app/zh
# https://chatboxai.app/install?download=darwin-aarch64
# https://chatboxai.app/install?download=darwin-x86_64
# == cherry box
# = vscode
# centos的remote-ssh需要低于1.99.0——因为有glibc和kennel版本限制
# 网页: https://code.visualstudio.com/updates/v1_98
curl https://update.code.visualstudio.com/1.98.2/darwin-arm64/stable
# intel
curl https://update.code.visualstudio.com/1.98.2/darwin/stable
# == 插件、ai、
# = 思源笔记
# = obsidian
# = UI测试
# == 网易airtest
# = 远程桌面
# == anydesk
# == 向日葵
# = transmit破解版
# = 腾讯会议
# = 解压专家Oka
# = orbstack
# = 终端
# == alacritty
# == iterm
# == wezterm
# = VPN
# = Xcode、xcode command line
# xcode可以在app store中直接下载即为当前os版本可用的
# = another redis desktop manager
# = robo 3t
# xmind
# = 预览
# utool
# 爱思助手
# = 时间段自动改主题:中午
sudo cp "$HOME"/.config/.bin/.Dependencies/setup-kit/osx/com.user.switchtheme.plist ~/Library/LaunchAgents/com.user.switchtheme.plist
sudo launchctl load ~/Library/LaunchAgents/com.user.switchtheme.plist
#> 对于系统级的代理(放在 /Library/LaunchDaemons 目录下),需要使用 sudo 并指定 system
#~ sudo launchctl bootstrap system /Library/LaunchDaemons/com.user.switchtheme.plist
#> 语法错误: 检查 .plist 文件的语法是否正确
# plutil -lint ~/Library/LaunchAgents/com.user.switchtheme.plist
#> 查看系统日志获取更多信息
# log show --predicate 'process == "launchd"' --info --last 1h

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.switchtheme</string>
<!-- 切换到深色主题 -->
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>12</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
<dict>
<key>Hour</key>
<integer>14</integer>
<key>Minute</key>
<integer>3</integer>
</dict>
</array>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>
if [[ $(date +%H) == "12" ]]; then
osascript /Users/woan/.config/.bin/.Dependencies/setup-kit/osx/switchTopic.scpt dark;
elif [[ $(date +%H) == "14" ]]; then
osascript /Users/woan/.config/.bin/.Dependencies/setup-kit/osx/switchTopic.scpt light;
fi
</string>
</array>
<key>RunAtLoad</key>
<true />
</dict>
</plist>

19
osx/switchTopic.scpt Normal file
View File

@ -0,0 +1,19 @@
on run argv
-- argv 是一个包含参数的列表
set action to item 1 of argv
if action is "dark" then
tell application "System Events"
tell appearance preferences
set dark mode to true
end tell
end tell
else if action is "light" then
tell application "System Events"
tell appearance preferences
set dark mode to false
end tell
end tell
else
display dialog "未知的参数: " & action
end if
end run

View File

@ -6,12 +6,17 @@
> 静默但输出错误信息,并跟随重定向 > 静默但输出错误信息,并跟随重定向
克隆 dev 分支(`-b`,默认)并进行初始化(`-i`
```bash ```bash
curl -sSL https://gitea.yever.top/Hawkin/setup-kit/raw/main/config-os-and-apps.sh | bash curl -sSL https://gitea.yever.top/Hawkin/setup-kit/raw/main/config-os-and-apps.sh | bash -s -- -ib dev
``` ```
指定分支(`-b`)但不进行初始化:
````bash
curl -sSL https://gitea.yever.top/Hawkin/setup-kit/raw/main/config-os-and-apps.sh | bash -s -- -b dev
```bash ```bash
wget -qO- https://gitea.yever.top/Hawkin/setup-kit/raw/main/config-os-and-apps.sh | bash wget -qO- https://gitea.yever.top/Hawkin/setup-kit/raw/main/config-os-and-apps.sh | bash
``` ````