summaryrefslogtreecommitdiff
path: root/assets/info/regenerate_dir.sh
blob: 159bfc33dc7bf72ff0c365da0dff9c66962ae48c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash

# Set the info directory
INFO_DIR="${HOME}/.emacs.d/assets/info"

cd "$INFO_DIR" || { echo "Error: Cannot access $INFO_DIR"; exit 1; }

# Remove any existing dir
[[ -f dir ]] && rm dir

echo "Processing info files..."

success=0
failed=0

# Process all info files
for file in *.info *.info.gz; do
	[[ ! -e "$file" ]] && continue
	[[ "$file" == "dir" ]] && continue

	# Skip multi-part files
	if [[ "$file" =~ -[0-9]+\.info ]]; then
		continue
	fi

	echo -n "  Adding: $file ... "

	# Try with more explicit options
	if install-info "$file" "$INFO_DIR"/dir ; then
		echo "OK"
		((success++))
	else
		echo "FAILED"
		((failed++))
	fi
done

echo ""
echo "----------------------------------------"
echo "Summary:"
echo "  Successfully added: $success files"
echo "  Failed to add: $failed files"
echo ""

# Count actual entries in the dir file
ENTRY_COUNT=$(grep -c '^\*.*:.*\.' dir 2>/dev/null || echo "0")
echo "Total entries in dir file: $ENTRY_COUNT"
echo ""

# Show first few entries as confirmation
if [[ $ENTRY_COUNT -gt 0 ]]; then
	echo "Sample of entries added:"
	grep '^\*.*:.*\.' dir | head -5
else
	echo "WARNING: No entries found in dir file!"
	echo "Showing first 20 lines of dir file for debugging:"
	head -20 dir
fi

echo ""
echo "Done! Restart Emacs and press C-h i to see the updated info directory."