Add portable Zed Gist sync configuration

This commit is contained in:
2026-07-29 17:11:18 +08:00
commit 13cf327f48
17 changed files with 1749 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env sh
set -eu
source_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
target="${XDG_CONFIG_HOME:-$HOME/.config}/zed"
timestamp=$(date +%Y%m%d-%H%M%S)
backup="$target/backups/portable-install-$timestamp"
mkdir -p "$target/scripts" "$backup"
for name in settings.json keymap.json tasks.json; do
if [ -f "$target/$name" ]; then
cp "$target/$name" "$backup/$name"
fi
done
cp "$source_dir/settings.json" "$target/settings.json"
cp "$source_dir/keymap.json" "$target/keymap.json"
cp "$source_dir/scripts/toggle-file-scan-exclusions.mjs" "$target/scripts/toggle-file-scan-exclusions.mjs"
cp "$source_dir/scripts/file-exclusions.json" "$target/scripts/file-exclusions.json"
cp "$source_dir/scripts/zed-settings-sync.mjs" "$target/scripts/zed-settings-sync.mjs"
if [ ! -f "$target/scripts/settings-sync.json" ]; then
cp "$source_dir/scripts/settings-sync.json" "$target/scripts/settings-sync.json"
fi
node - "$source_dir/tasks.json" "$target/tasks.json" "$target/scripts/toggle-file-scan-exclusions.mjs" "$target/scripts/zed-settings-sync.mjs" <<'NODE'
const fs = require("node:fs");
const [source, target, toggleScript, syncScript] = process.argv.slice(2);
const tasks = fs.readFileSync(source, "utf8")
.replaceAll("__TOGGLE_SCRIPT__", toggleScript)
.replaceAll("__SYNC_SCRIPT__", syncScript);
fs.writeFileSync(target, tasks);
NODE
printf 'Installed Zed configuration to %s\n' "$target"
printf 'Previous configuration backed up to %s\n' "$backup"