feat: add user scripts (backup-menu, ssh-pick, proj) and backup reminder

This commit is contained in:
Dmitry
2026-05-13 19:39:32 +03:00
parent 28914ea128
commit babe53d929
5 changed files with 183 additions and 8 deletions
+47
View File
@@ -266,6 +266,53 @@ sshp-restart() {
}
# _backup_reminder - проверить давность последнего бэкапа (вызывается из .zshrc)
_backup_reminder() {
local state_file="${XDG_STATE_HOME:-$HOME/.local/state}/backup-last-run"
local threshold=$(( 2 * 24 * 3600 )) # 2 дня в секундах
local now
now=$(date +%s)
if [[ ! -f "$state_file" ]]; then
print -P "%F{yellow}⚠ Бэкап не запускался. Запусти: backup-menu%f"
return
fi
local last
last=$(cat "$state_file")
local diff=$(( now - last ))
if (( diff > threshold )); then
local days=$(( diff / 86400 ))
print -P "%F{yellow}⚠ Последний бэкап: ${days} дн. назад. Запусти: backup-menu%f"
fi
}
# proj - перейти в проект через fzf
proj() {
local base="${PROJECTS_DIR:-$HOME/Documents/Projects}"
if [[ ! -d "$base" ]]; then
echo "Projects dir not found: $base"
return 1
fi
local target
if command -v fzf &>/dev/null; then
target=$(find "$base" -maxdepth 2 -mindepth 1 -type d \
\( -name .git -o -name node_modules -o -name .venv \) -prune \
-o -type d -print \
| sed "s|$base/||" \
| fzf --prompt "proj > " --height=40% --reverse) || return 0
elif [[ -n "$1" ]]; then
target="$1"
else
ls "$base"
return 0
fi
cd "$base/$target"
}
activate() {
local venv_dir=""
if [[ -d ".venv" ]]; then