mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 11:31:46 +00:00
✨ Support shorter mo use
This commit is contained in:
24
GUIDE.md
24
GUIDE.md
@@ -65,9 +65,11 @@ brew install tw93/tap/mole
|
||||
在终端中输入以下命令并按回车:
|
||||
|
||||
```bash
|
||||
mole
|
||||
mo
|
||||
```
|
||||
|
||||
如果提示找不到命令,也可以输入 `mole`(功能完全相同)。
|
||||
|
||||
2. **了解界面操作**
|
||||
- 用键盘的 `↑` `↓` 方向键 选择菜单项
|
||||
- 按 `空格键` 选中或取消选中
|
||||
@@ -82,8 +84,8 @@ brew install tw93/tap/mole
|
||||
|
||||
**首次使用强烈建议:**
|
||||
|
||||
1. **预览模式:** 先运行 `mole clean --dry-run` 查看将删除的内容,不会真的删除任何文件
|
||||
2. **白名单保护:** 使用 `mole clean --whitelist` 保护重要的缓存文件
|
||||
1. **预览模式:** 先运行 `mo clean --dry-run` 查看将删除的内容,不会真的删除任何文件
|
||||
2. **白名单保护:** 使用 `mo clean --whitelist` 保护重要的缓存文件
|
||||
3. **谨慎使用:** 如果你的 Mac 非常重要(生产环境、关键工作设备),建议等待 Mole 更加成熟稳定后再使用
|
||||
|
||||
### 清理垃圾文件
|
||||
@@ -91,7 +93,7 @@ brew install tw93/tap/mole
|
||||
**安全预览模式(推荐第一次使用):**
|
||||
|
||||
```bash
|
||||
mole clean --dry-run
|
||||
mo clean --dry-run
|
||||
```
|
||||
|
||||
这个命令只会**显示**哪些文件会被清理,**不会真的删除**。你可以先看看效果再决定。
|
||||
@@ -99,7 +101,7 @@ mole clean --dry-run
|
||||
**管理白名单(保护重要缓存):**
|
||||
|
||||
```bash
|
||||
mole clean --whitelist
|
||||
mo clean --whitelist
|
||||
```
|
||||
|
||||
交互式选择哪些缓存不要删除,比如开发工具的大型缓存(Homebrew、Gradle 等)。
|
||||
@@ -107,7 +109,7 @@ mole clean --whitelist
|
||||
**正式清理:**
|
||||
|
||||
```bash
|
||||
mole clean
|
||||
mo clean
|
||||
```
|
||||
|
||||
会清理系统缓存、日志、临时文件等,释放磁盘空间。Mole 很安全,只删除可重新生成的文件。
|
||||
@@ -115,7 +117,7 @@ mole clean
|
||||
### 卸载应用(彻底删除)
|
||||
|
||||
```bash
|
||||
mole uninstall
|
||||
mo uninstall
|
||||
```
|
||||
|
||||
这个功能会:
|
||||
@@ -129,7 +131,7 @@ mole uninstall
|
||||
### 查看帮助
|
||||
|
||||
```bash
|
||||
mole --help
|
||||
mo --help
|
||||
```
|
||||
|
||||
可以查看所有可用的命令和说明。
|
||||
@@ -137,7 +139,7 @@ mole --help
|
||||
### 磁盘空间分析 🆕
|
||||
|
||||
```bash
|
||||
mole analyze
|
||||
mo analyze
|
||||
```
|
||||
|
||||
交互式查看哪些文件和文件夹最占空间,帮助你快速找到并清理大文件。
|
||||
@@ -190,9 +192,9 @@ mole analyze
|
||||
|
||||
### 如何更新和卸载 Mole?
|
||||
|
||||
**更新:** 一键安装用 `mole update` · Homebrew 用 `brew upgrade mole`(检测不到新版本?先运行 `brew update`)
|
||||
**更新:** 一键安装用 `mo update` · Homebrew 用 `brew upgrade mole`(检测不到新版本?先运行 `brew update`)
|
||||
|
||||
**卸载:** 任何安装方式都用 `mole remove`(会自动识别安装方式,清理所有相关文件)
|
||||
**卸载:** 任何安装方式都用 `mo remove`(会自动识别安装方式,清理所有相关文件)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ brew install tw93/tap/mole
|
||||
**Run:**
|
||||
|
||||
```bash
|
||||
mo # Shortcut alias for Mole
|
||||
mole # Interactive menu
|
||||
mole clean # System cleanup
|
||||
mole clean --dry-run # Preview mode
|
||||
@@ -58,6 +59,8 @@ mole remove # Remove Mole from system
|
||||
mole --help # Show help
|
||||
```
|
||||
|
||||
Prefer the shorter alias `mo` for every command; `mole` remains available.
|
||||
|
||||
> Highly recommended start with `--dry-run` to preview, enable `--whitelist` to protect caches
|
||||
|
||||
## Features
|
||||
|
||||
26
install.sh
26
install.sh
@@ -235,6 +235,21 @@ install_files() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install mo alias for Mole if available
|
||||
if [[ -f "$SOURCE_DIR/mo" ]]; then
|
||||
if [[ "$source_dir_abs" == "$install_dir_abs" ]]; then
|
||||
log_info "mo alias already present in $INSTALL_DIR"
|
||||
else
|
||||
if [[ "$INSTALL_DIR" == "/usr/local/bin" ]] && [[ ! -w "$INSTALL_DIR" ]]; then
|
||||
sudo cp "$SOURCE_DIR/mo" "$INSTALL_DIR/mo"
|
||||
sudo chmod +x "$INSTALL_DIR/mo"
|
||||
else
|
||||
cp "$SOURCE_DIR/mo" "$INSTALL_DIR/mo"
|
||||
chmod +x "$INSTALL_DIR/mo"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy configuration and modules
|
||||
if [[ -d "$SOURCE_DIR/bin" ]]; then
|
||||
local source_bin_abs="$(cd "$SOURCE_DIR/bin" && pwd)"
|
||||
@@ -337,12 +352,14 @@ print_usage_summary() {
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
|
||||
echo " mo # Shortcut alias for Mole"
|
||||
echo " mole # Interactive menu"
|
||||
echo " mole clean # System cleanup"
|
||||
echo " mole uninstall # Remove applications"
|
||||
echo " mole update # Update Mole to the latest version"
|
||||
echo " mole --version # Show installed version"
|
||||
else
|
||||
echo " $INSTALL_DIR/mo # Shortcut alias for Mole"
|
||||
echo " $INSTALL_DIR/mole # Interactive menu"
|
||||
echo " $INSTALL_DIR/mole clean # System cleanup"
|
||||
echo " $INSTALL_DIR/mole uninstall # Remove applications"
|
||||
@@ -366,6 +383,15 @@ uninstall_mole() {
|
||||
log_success "Removed executable from $INSTALL_DIR"
|
||||
fi
|
||||
|
||||
if [[ -f "$INSTALL_DIR/mo" ]]; then
|
||||
if [[ "$INSTALL_DIR" == "/usr/local/bin" ]] && [[ ! -w "$INSTALL_DIR" ]]; then
|
||||
sudo rm -f "$INSTALL_DIR/mo"
|
||||
else
|
||||
rm -f "$INSTALL_DIR/mo"
|
||||
fi
|
||||
log_success "Removed mo alias from $INSTALL_DIR"
|
||||
fi
|
||||
|
||||
# Ask before removing config directory
|
||||
if [[ -d "$CONFIG_DIR" ]]; then
|
||||
echo ""
|
||||
|
||||
4
mo
Executable file
4
mo
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
# Lightweight alias to run Mole via `mo`
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
exec "$SCRIPT_DIR/mole" "$@"
|
||||
37
mole
37
mole
@@ -123,10 +123,8 @@ show_version() {
|
||||
show_help() {
|
||||
show_brand_banner
|
||||
echo
|
||||
printf "%s%s%s\n" "$BLUE" "USAGE" "$NC"
|
||||
printf " %s%s%s [command]\n\n" "$GREEN" "mole" "$NC"
|
||||
|
||||
printf "%s%s%s\n" "$BLUE" "COMMANDS" "$NC"
|
||||
printf " %s%-28s%s %s\n" "$GREEN" "mo" "$NC" "Shortcut alias for Mole"
|
||||
printf " %s%-28s%s %s\n" "$GREEN" "mole" "$NC" "Interactive main menu"
|
||||
printf " %s%-28s%s %s\n" "$GREEN" "mole clean" "$NC" "Deeper system cleanup"
|
||||
printf " %s%-28s%s %s\n" "$GREEN" "mole clean --dry-run" "$NC" "Preview cleanup (no deletions)"
|
||||
@@ -212,6 +210,7 @@ remove_mole() {
|
||||
# Detect all installations
|
||||
local is_homebrew=false
|
||||
local -a manual_installs=()
|
||||
local -a alias_installs=()
|
||||
|
||||
# Check Homebrew
|
||||
if command -v brew >/dev/null 2>&1 && brew list mole >/dev/null 2>&1; then
|
||||
@@ -234,6 +233,18 @@ remove_mole() {
|
||||
fi
|
||||
done
|
||||
|
||||
local -a alias_candidates=(
|
||||
"/usr/local/bin/mo"
|
||||
"$HOME/.local/bin/mo"
|
||||
"/opt/local/bin/mo"
|
||||
)
|
||||
|
||||
for alias in "${alias_candidates[@]}"; do
|
||||
if [[ -f "$alias" ]]; then
|
||||
alias_installs+=("$alias")
|
||||
fi
|
||||
done
|
||||
|
||||
# Show what will be removed
|
||||
echo "This will remove:"
|
||||
echo ""
|
||||
@@ -253,10 +264,16 @@ remove_mole() {
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ${#alias_installs[@]} -gt 0 ]]; then
|
||||
for alias in "${alias_installs[@]}"; do
|
||||
echo -e " ${GREEN}✓${NC} $alias"
|
||||
done
|
||||
fi
|
||||
|
||||
echo -e " ${GREEN}✓${NC} ~/.config/mole/ (configuration)"
|
||||
echo -e " ${GREEN}✓${NC} ~/.cache/mole/ (cache)"
|
||||
|
||||
if [[ "$is_homebrew" == "false" && ${#manual_installs[@]} -eq 0 ]]; then
|
||||
if [[ "$is_homebrew" == "false" && ${#manual_installs[@]} -eq 0 && ${#alias_installs[@]} -eq 0 ]]; then
|
||||
echo ""
|
||||
echo -e "${YELLOW}No Mole installation detected${NC}"
|
||||
exit 0
|
||||
@@ -310,6 +327,18 @@ remove_mole() {
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ${#alias_installs[@]} -gt 0 ]]; then
|
||||
for alias in "${alias_installs[@]}"; do
|
||||
if [[ -f "$alias" ]]; then
|
||||
if rm -f "$alias" 2>/dev/null; then
|
||||
log_success "Removed alias: $alias"
|
||||
else
|
||||
log_warning "Could not remove alias $alias (may need sudo)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Clean up configuration and cache (both methods)
|
||||
if [[ -d "$HOME/.config/mole" ]]; then
|
||||
rm -rf "$HOME/.config/mole" 2>/dev/null && log_success "Removed configuration"
|
||||
|
||||
Reference in New Issue
Block a user