Commit d0f0a76

Eric Bower  ·  2026-06-16 23:24:09 -0400 EDT
parent 8a10647
fix: revert to simple arrays
1 files changed,  +36, -21
+36, -21
 1@@ -1,23 +1,37 @@
 2 #!/usr/bin/env bash
 3 
 4-declare -A TRACKED
 5-TRACKED=(
 6-  [bin/]="$HOME/.local/bin/"
 7-  [dot_pi/agent/extensions/]="$HOME/.pi/agent/extensions/"
 8-  [dot_pi/agent/settings.json]="$HOME/.pi/agent/settings.json"
 9-  [dot_config/]="$HOME/.config/"
10-  [dot/gitconfig]="$HOME/.gitconfig"
11-  [dot/mbsyncrc]="$HOME/.mbsyncrc"
12-  [dot_gnupg/gpg-agent.conf]="$HOME/.gnupg/gpg-agent.conf"
13-  [dot_ssh/config]="$HOME/.ssh/config"
14-  [dot_mblaze/mblaze]="$HOME/.mblaze/profile"
15-  [dot/msmtprc]="$HOME/.msmtprc"
16-  [dot/npmrc]="$HOME/.npmrc"
17-  [dot/editorconfig]="$HOME/.editorconfig"
18+TRACKED_FILES=(
19+  bin/
20+  dot_pi/agent/extensions/
21+  dot_pi/agent/settings.json
22+  dot_config/
23+  dot/gitconfig
24+  dot/mbsyncrc
25+  dot_gnupg/gpg-agent.conf
26+  dot_ssh/config
27+  dot_mblaze/mblaze
28+  dot/msmtprc
29+  dot/npmrc
30+  dot/editorconfig
31+)
32+
33+TRACKED_LOCATIONS=(
34+  ~/.local/bin/
35+  ~/.pi/agent/extensions/
36+  ~/.pi/agent/settings.json
37+  ~/.config/
38+  ~/.gitconfig
39+  ~/.mbsyncrc
40+  ~/.gnupg/gpg-agent.conf
41+  ~/.ssh/config
42+  ~/.mblaze/profile
43+  ~/.msmtprc
44+  ~/.npmrc
45+  ~/.editorconfig
46 )
47 
48 find_files() {
49-  local tfo="$1"
50+  local tfo="${TRACKED_FILES[$1]}"
51   if [[ ${tfo} == */ ]]; then
52     find "$PWD/${tfo}" -type d -exec find {} -maxdepth 1 -type f \; | sed "s|$PWD/${tfo}||" | sed "s|^/||"
53   fi
54@@ -40,21 +54,22 @@ unlink_file() {
55 
56 case "${1:-link}" in
57   link)
58-    for tf in "${!TRACKED[@]}"; do
59-      tl="${TRACKED[$tf]}"
60+    for ((i = 0; i < ${#TRACKED_FILES[@]}; ++i)); do
61+      tf="${TRACKED_FILES[$i]}"
62+      tl="${TRACKED_LOCATIONS[$i]}"
63       link_file "$PWD/${tf}" "${tl}"
64       while IFS= read -r file; do
65         link_file "$PWD/${tf}${file}" "${tl}${file}"
66-      done < <(find_files "$tf")
67+      done < <(find_files "$i")
68     done
69     ;;
70   cleanup)
71-    for tf in "${!TRACKED[@]}"; do
72-      tl="${TRACKED[$tf]}"
73+    for ((i = 0; i < ${#TRACKED_FILES[@]}; ++i)); do
74+      tl="${TRACKED_LOCATIONS[$i]}"
75       unlink_file "${tl}"
76       while IFS= read -r file; do
77         unlink_file "${tl}${file}"
78-      done < <(find_files "$tf")
79+      done < <(find_files "$i")
80     done
81     ;;
82   *)