feat: add ff pouch to clone and install pouch
Clone https://git.yumee.top/laily/.pouch to ~/.pouch and run install.sh.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# Completions for ff command
|
# Completions for ff command
|
||||||
complete -c ff -f
|
complete -c ff -f
|
||||||
set -l ff_subcommands reload edit fish dotfile pon poff pst make script s update help region ssh init copy dirsize help region
|
set -l ff_subcommands reload edit fish dotfile pon poff pst make script s update help region ssh init copy dirsize pouch help region
|
||||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "reload" -d "Reload fish configuration"
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "reload" -d "Reload fish configuration"
|
||||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "edit" -d "Edit custom fish configuration"
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "edit" -d "Edit custom fish configuration"
|
||||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "fish" -d "Change to fish config directory"
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "fish" -d "Change to fish config directory"
|
||||||
@@ -16,6 +16,8 @@ complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "help" -d
|
|||||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "region" -d "Toggle or set CN_REGION (mirror/proxy region)"
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "region" -d "Toggle or set CN_REGION (mirror/proxy region)"
|
||||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "ssh" -d "SSH init / copy key + add host / copy config to remote"
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "ssh" -d "SSH init / copy key + add host / copy config to remote"
|
||||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "dirsize" -d "Show directory sizes"
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "dirsize" -d "Show directory sizes"
|
||||||
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "pouch" -d "Clone and install pouch to ~/.pouch"
|
||||||
|
complete -c ff -n "__fish_seen_subcommand_from pouch" -s h -l help -d "Show help"
|
||||||
|
|
||||||
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s a -l all -d "Recursively show all subdirectories"
|
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s a -l all -d "Recursively show all subdirectories"
|
||||||
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s d -l depth -d "Recursion depth (default 1)" -r
|
complete -c ff -n "__fish_seen_subcommand_from dirsize" -s d -l depth -d "Recursion depth (default 1)" -r
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ function ff
|
|||||||
"region|Toggle or set CN_REGION (mirror/proxy region)" \
|
"region|Toggle or set CN_REGION (mirror/proxy region)" \
|
||||||
"ssh|SSH init, copy key + add host config, or copy config to remote" \
|
"ssh|SSH init, copy key + add host config, or copy config to remote" \
|
||||||
"dirsize|Show directory sizes (du wrapper)" \
|
"dirsize|Show directory sizes (du wrapper)" \
|
||||||
|
"pouch|Clone and install pouch to ~/.pouch" \
|
||||||
"help|Show this help message"
|
"help|Show this help message"
|
||||||
|
|
||||||
# 确保 execute-script 可用(在 fish 自动加载前手动引入一次)
|
# 确保 execute-script 可用(在 fish 自动加载前手动引入一次)
|
||||||
@@ -116,6 +117,14 @@ function ff
|
|||||||
echo "Error: dirsize script not found at $script_path"
|
echo "Error: dirsize script not found at $script_path"
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
case pouch
|
||||||
|
set -l script_path ~/.dotfile/script/pouch-install.sh
|
||||||
|
if test -f $script_path
|
||||||
|
bash $script_path $argv[2..-1]
|
||||||
|
else
|
||||||
|
echo "Error: pouch-install script not found at $script_path"
|
||||||
|
return 1
|
||||||
|
end
|
||||||
case region
|
case region
|
||||||
if not functions -q region_toggle
|
if not functions -q region_toggle
|
||||||
source ~/.dotfile/fish/functions/region.fish
|
source ~/.dotfile/fish/functions/region.fish
|
||||||
|
|||||||
Executable
+76
@@ -0,0 +1,76 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 从 git.yumee.top 克隆并安装 pouch 到 ~/.pouch
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source "$SCRIPT_DIR/common/help.sh"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<'EOF'
|
||||||
|
用法: pouch-install
|
||||||
|
|
||||||
|
从 https://git.yumee.top/laily/.pouch 克隆到 ~/.pouch,
|
||||||
|
并运行仓库内 install.sh 安装 CLI。
|
||||||
|
|
||||||
|
~/.pouch 已是 pouch 仓库时跳过克隆,直接跑 install.sh。
|
||||||
|
路径已占用且不是 pouch 仓库时拒绝覆盖。
|
||||||
|
|
||||||
|
选项:
|
||||||
|
-h, --help 显示此帮助
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
dotfile_help_requested "${1:-}" && dotfile_show_help
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
POUCH_DIR="${HOME}/.pouch"
|
||||||
|
POUCH_URL="https://git.yumee.top/laily/.pouch"
|
||||||
|
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
RED='\033[0;31m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
need_cmd() {
|
||||||
|
if ! command -v "$1" >/dev/null 2>&1; then
|
||||||
|
echo -e "${RED}缺少命令: $1${NC}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
is_pouch_repo() {
|
||||||
|
[ -d "$POUCH_DIR/skills" ] && [ -f "$POUCH_DIR/install.sh" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
need_cmd git
|
||||||
|
need_cmd python3
|
||||||
|
|
||||||
|
if [ -e "$POUCH_DIR" ] || [ -L "$POUCH_DIR" ]; then
|
||||||
|
if is_pouch_repo; then
|
||||||
|
echo -e "${GREEN}${POUCH_DIR} 已存在,跳过克隆${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${RED}${POUCH_DIR} 已存在且不是 pouch 仓库,拒绝覆盖${NC}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}正在克隆 ${POUCH_URL} 到 ${POUCH_DIR}...${NC}"
|
||||||
|
git clone "$POUCH_URL" "$POUCH_DIR"
|
||||||
|
echo -e "${GREEN}已克隆到 ${POUCH_DIR}${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is_pouch_repo; then
|
||||||
|
echo -e "${RED}${POUCH_DIR} 缺少 skills/ 或 install.sh,仓库可能不完整${NC}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${YELLOW}正在运行 ${POUCH_DIR}/install.sh...${NC}"
|
||||||
|
bash "$POUCH_DIR/install.sh"
|
||||||
|
export PATH="${HOME}/.local/bin:${PATH}"
|
||||||
|
|
||||||
|
if command -v pouch >/dev/null 2>&1; then
|
||||||
|
echo -e "${GREEN}pouch 安装成功: $(command -v pouch)${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}pouch 已写入 ~/.local/bin,当前会话请执行:${NC}"
|
||||||
|
echo ' export PATH="$HOME/.local/bin:$PATH"'
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user