This commit is contained in:
Ray Elliott 2026-10-27 13:27:51 +00:00
commit 97d53308df
2 changed files with 58 additions and 0 deletions

View file

@ -64,6 +64,7 @@ The loader sources every readable `bashrc.d/*.bash` file in lexical order:
- `50-completions.bash`: command-specific completion setup. - `50-completions.bash`: command-specific completion setup.
- `60-directory-notes.bash`: `TODO.md` and `.autonote.md` display after `cd`. - `60-directory-notes.bash`: `TODO.md` and `.autonote.md` display after `cd`.
- `70-development.bash`: OpenCode and Pyenv initialization. - `70-development.bash`: OpenCode and Pyenv initialization.
- `90-memory-question.bash`: daily shell-memory question and `answerpls`.
Keep cross-module dependencies explicit through this numbering. New modules Keep cross-module dependencies explicit through this numbering. New modules
should own one coherent area rather than becoming another general-purpose RC. should own one coherent area rather than becoming another general-purpose RC.

View file

@ -0,0 +1,57 @@
# shellcheck shell=bash
_memory_file="${XDG_CONFIG_HOME:-$HOME/.config}/profile/memory.tsv"
_memory_question_color='\033[38;5;11m'
_memory_names=()
_memory_questions=()
_memory_answers=()
declare -A _memory_seen=()
_memory_invalid=0
_memory_line_number=0
if [[ -r "$_memory_file" ]]; then
while IFS=$'\t' read -r _memory_name _memory_question _memory_answer _memory_extra; do
((_memory_line_number++))
if [[ -z "$_memory_name$_memory_question$_memory_answer$_memory_extra" ]]; then
continue
fi
if [[ -z "$_memory_name" || -z "$_memory_question" || -z "$_memory_answer" || -n "$_memory_extra" ]]; then
printf 'Invalid memory question on line %d.\n' "$_memory_line_number" >&2
_memory_invalid=1
continue
fi
if [[ -n ${_memory_seen[$_memory_name]:-} ]]; then
printf 'Duplicate memory question for %s on line %d.\n' "$_memory_name" "$_memory_line_number" >&2
_memory_invalid=1
continue
fi
_memory_seen[$_memory_name]=1
_memory_names+=("$_memory_name")
_memory_questions+=("$_memory_question")
_memory_answers+=("$_memory_answer")
done < "$_memory_file"
else
printf 'Memory question file is unavailable: %s\n' "$_memory_file" >&2
_memory_invalid=1
fi
if [[ $_memory_invalid -eq 0 && ${#_memory_names[@]} -gt 0 ]]; then
_memory_day=$(date -d "$(date +%F) 00:00" +%s)
_memory_index=$(( (_memory_day / 86400) % ${#_memory_names[@]} ))
_MEMORY_ANSWER=${_memory_answers[$_memory_index]}
answerpls() {
printf '%s\n' "$_MEMORY_ANSWER"
}
printf '%b%s%b (answerpls)\n\n' \
"$_memory_question_color" "${_memory_questions[$_memory_index]}" "$_NC"
fi
unset _memory_file _memory_question_color _memory_names _memory_questions _memory_answers
unset _memory_seen _memory_invalid _memory_line_number _memory_name _memory_question
unset _memory_answer _memory_extra _memory_day _memory_index