Files
microdao-daarion/scripts/logging/shell-integration.sh
Apple 744c149300
Some checks failed
Build and Deploy Docs / build-and-deploy (push) Has been cancelled
Add automated session logging system
- Created logs/ structure (sessions, operations, incidents)
- Added session-start/log/end scripts
- Installed Git hooks for auto-logging commits/pushes
- Added shell integration for zsh
- Created CHANGELOG.md
- Documented today's session (2026-01-10)
2026-01-10 04:53:17 -08:00

82 lines
2.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# ============================================================
# shell-integration.sh — Інтеграція логування з shell
# ============================================================
# Додайте до ~/.zshrc або ~/.bashrc:
# source /Users/apple/github-projects/microdao-daarion/scripts/logging/shell-integration.sh
# ============================================================
# Шляхи
export DAARION_PROJECT="/Users/apple/github-projects/microdao-daarion"
export DAARION_LOGS="$DAARION_PROJECT/logs"
# Aliases для швидкого доступу
alias daarion="cd $DAARION_PROJECT"
alias session-start="$DAARION_PROJECT/scripts/logging/session-start.sh"
alias session-log="$DAARION_PROJECT/scripts/logging/session-log.sh"
alias session-end="$DAARION_PROJECT/scripts/logging/session-end.sh"
alias git-sync="$DAARION_PROJECT/scripts/git-sync-all.sh"
# Функція для логування важливих команд
daarion-log() {
local cmd="$*"
local date=$(date +%Y-%m-%d)
local time=$(date +%H:%M:%S)
local session_file="$DAARION_LOGS/sessions/${date}.md"
if [ -f "$session_file" ]; then
echo "- **$time** — \`$cmd\`" >> "$session_file"
fi
# Виконати команду
eval "$cmd"
}
# Функція для швидкого запису нотатки
daarion-note() {
local note="$*"
local date=$(date +%Y-%m-%d)
local time=$(date +%H:%M)
local session_file="$DAARION_LOGS/sessions/${date}.md"
if [ ! -f "$session_file" ]; then
mkdir -p "$DAARION_LOGS/sessions"
cat > "$session_file" << EOF
# 📅 Session Log: $date
**Проєкт:** DAARION & MicroDAO
---
## 📋 Нотатки
EOF
fi
echo "- **$time** — 📝 $note" >> "$session_file"
echo "✅ Нотатку додано"
}
# Автоматичне логування при вході в директорію проєкту
daarion-auto-session() {
if [[ "$PWD" == "$DAARION_PROJECT"* ]]; then
local date=$(date +%Y-%m-%d)
local session_file="$DAARION_LOGS/sessions/${date}.md"
if [ ! -f "$session_file" ]; then
echo "📝 Нова сесія для $date"
session-start "Автоматична сесія"
fi
fi
}
# Hook для zsh (опціонально)
if [ -n "$ZSH_VERSION" ]; then
# Додати до chpwd hook
autoload -U add-zsh-hook
add-zsh-hook chpwd daarion-auto-session
fi
# Повідомлення при завантаженні
echo "🔧 DAARION logging loaded. Commands: session-start, session-log, session-end, daarion-note"