-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·141 lines (115 loc) · 4.74 KB
/
install.sh
File metadata and controls
executable file
·141 lines (115 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Function to print messages based on language choice
print_msg() {
local msg_en="$1"
local msg_zh="$2"
if [ -z "$LANG_CHOICE" ]; then
echo -e "$msg_en / $msg_zh"
elif [ "$LANG_CHOICE" = "1" ]; then
echo -e "$msg_zh"
else
echo -e "$msg_en"
fi
}
# Copy file if destination file does not exist
copy_if_missing() {
local src="$1"
local dest="$2"
if [ ! -f "$dest" ]; then
cp "$src" "$dest"
fi
}
echo "================================================"
echo " Life Coach System Installation Script "
echo " Life Coach 系统安装脚本 "
echo "================================================"
echo ""
# Language Selection
echo "Please select your language / 请选择你的语言:"
echo "1) 中文 (Chinese)"
echo "2) English"
read -p "Enter choice / 输入选项 (1 or 2): " LANG_CHOICE
if [ "$LANG_CHOICE" != "1" ] && [ "$LANG_CHOICE" != "2" ]; then
echo "Invalid choice. Defaulting to English. / 选择无效,默认使用英文。"
LANG_CHOICE="2"
fi
if [ "$LANG_CHOICE" = "1" ]; then
SKILL_FILE="$SCRIPT_DIR/SKILL.md"
else
SKILL_FILE="$SCRIPT_DIR/SKILL_en.md"
fi
echo ""
print_msg "Please enter the absolute path to your Obsidian Vault." "请输入你的 Obsidian 库的绝对路径。"
print_msg "(e.g., /Users/yourname/Documents/Obsidian or /home/yourname/Documents/Obsidian)" "(例如: /Users/yourname/Documents/Obsidian 或 /home/yourname/Documents/Obsidian)"
read -p "> " VAULT_PATH
# Expand tilde if present
eval VAULT_PATH="$VAULT_PATH"
if [ ! -d "$VAULT_PATH" ]; then
print_msg "Error: The directory '$VAULT_PATH' does not exist." "错误:目录 '$VAULT_PATH' 不存在。"
exit 1
fi
print_msg "Installing Life Coach to '$VAULT_PATH'..." "正在将 Life Coach 安装到 '$VAULT_PATH'..."
echo ""
# Determine language directory
if [ "$LANG_CHOICE" = "1" ]; then
LANG_DIR="zh"
else
LANG_DIR="en"
fi
# Copy files
print_msg "Copying templates and creating journal structure (without overwriting existing files)..." "正在复制模板并创建日志结构(不会覆盖已有文件)..."
mkdir -p "$VAULT_PATH/templates"
mkdir -p "$VAULT_PATH/journal"
cp -rn "$SCRIPT_DIR/templates/$LANG_DIR/." "$VAULT_PATH/templates/"
# Create clean journal structure (no sample history data)
mkdir -p "$VAULT_PATH/journal/vision_2028"
mkdir -p "$VAULT_PATH/journal/daily"
mkdir -p "$VAULT_PATH/journal/weekly"
# Install core strategy files only if missing
copy_if_missing "$SCRIPT_DIR/journal/$LANG_DIR/vision_2028/plan.md" "$VAULT_PATH/journal/vision_2028/plan.md"
copy_if_missing "$SCRIPT_DIR/journal/$LANG_DIR/vision_2028/anti-vision.md" "$VAULT_PATH/journal/vision_2028/anti-vision.md"
# Install goal template only if missing
GOAL_DEST="$VAULT_PATH/journal/vision_2028/2026/goal.md"
GOAL_TEMPLATE="$SCRIPT_DIR/templates/$LANG_DIR/goal_template.md"
mkdir -p "$(dirname "$GOAL_DEST")"
copy_if_missing "$GOAL_TEMPLATE" "$GOAL_DEST"
# Install NAV template only if missing
NAV_DEST="$VAULT_PATH/journal/nav_tracker.md"
NAV_TEMPLATE="$SCRIPT_DIR/templates/$LANG_DIR/nav_template.md"
copy_if_missing "$NAV_TEMPLATE" "$NAV_DEST"
# Tool Selection
echo ""
print_msg "Please select your AI Assistant / 请选择你的 AI 助手:" "Please select your AI Assistant / 请选择你的 AI 助手:"
echo "1) Claude Code"
echo "2) Codex"
echo "3) Qwen"
echo "4) Opencode"
read -p "$(print_msg "Enter choice / 输入选项 (1-4): " "Enter choice / 输入选项 (1-4): ")" TOOL_CHOICE
case "$TOOL_CHOICE" in
1) SKILLS_DIR="$HOME/.claude/skills"; TOOL_NAME="Claude Code" ;;
2) SKILLS_DIR="$HOME/.codex/skills"; TOOL_NAME="Codex" ;;
3) SKILLS_DIR="$HOME/.qwen/skills"; TOOL_NAME="Qwen" ;;
4) SKILLS_DIR="$HOME/.opencode/skills"; TOOL_NAME="Opencode" ;;
*) print_msg "Invalid choice. Defaulting to Claude Code. / 选择无效,默认使用 Claude Code。" "选择无效,默认使用 Claude Code。"; SKILLS_DIR="$HOME/.claude/skills"; TOOL_NAME="Claude Code" ;;
esac
# Configure Skill
DEST_SKILL_DIR="$SKILLS_DIR/life-coach"
mkdir -p "$DEST_SKILL_DIR"
DEST_SKILL_FILE="$DEST_SKILL_DIR/SKILL.md"
print_msg "Configuring $TOOL_NAME Skill..." "正在配置 $TOOL_NAME Skill..."
# Create a temporary file
TMP_FILE=$(mktemp)
# Replace the VAULT_ROOT line using awk globally
awk -v vault="$VAULT_PATH" '{
if ($0 ~ /^VAULT_ROOT = /) {
print "VAULT_ROOT = " vault
} else {
print $0
}
}' "$SKILL_FILE" > "$TMP_FILE"
mv "$TMP_FILE" "$DEST_SKILL_FILE"
echo ""
print_msg "Installation complete! 🎉" "安装完成!🎉"
print_msg "Please ensure $TOOL_NAME is running and use '/life-coach morning' to start." "请确保正在运行 $TOOL_NAME,并使用 '/life-coach morning' 开始。"
echo ""