From 2ffbc1ea842c99926dd1fe5f8f548f260331c710 Mon Sep 17 00:00:00 2001 From: Tim Evans Date: Sun, 7 Jun 2026 11:46:10 +0100 Subject: [PATCH] Make sync scripts cross-platform (Linux + macOS) Derive the memory project-key from $HOME (replacing / with -) instead of hardcoding the macOS -Users- path, so install.sh/sync.sh resolve ~/.claude/projects/-home-/memory on Linux and -Users- on macOS. Co-Authored-By: Claude Opus 4.8 (1M context) --- README.md | 5 +++-- install.sh | 5 ++++- sync.sh | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9617164..47c4ef1 100644 --- a/README.md +++ b/README.md @@ -41,5 +41,6 @@ git pull ## Memory path -Memory files live at `~/.claude/projects/-Users-/memory/`. The scripts resolve -`` via `whoami` automatically. +Memory files live under `~/.claude/projects//memory/`, where `` is +the home directory with `/` replaced by `-`. The scripts derive this from `$HOME` automatically, +so it resolves correctly on macOS (`-Users-`) and Linux (`-home-`). diff --git a/install.sh b/install.sh index 1ef1663..187db5b 100755 --- a/install.sh +++ b/install.sh @@ -8,7 +8,10 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CLAUDE_DIR="$HOME/.claude" USERNAME=$(whoami) -MEMORY_DIR="$CLAUDE_DIR/projects/-Users-${USERNAME}/memory" +# Claude Code encodes the project dir by replacing "/" with "-". +# Derive from $HOME so it works on macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x). +PROJECT_KEY="${HOME//\//-}" +MEMORY_DIR="$CLAUDE_DIR/projects/${PROJECT_KEY}/memory" echo "Installing Claude config for user: $USERNAME" diff --git a/sync.sh b/sync.sh index 1f00ad1..dcf0a90 100755 --- a/sync.sh +++ b/sync.sh @@ -6,8 +6,10 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CLAUDE_DIR="$HOME/.claude" -USERNAME=$(whoami) -MEMORY_DIR="$CLAUDE_DIR/projects/-Users-${USERNAME}/memory" +# Claude Code encodes the project dir by replacing "/" with "-". +# Derive from $HOME so it works on macOS (/Users/x -> -Users-x) and Linux (/home/x -> -home-x). +PROJECT_KEY="${HOME//\//-}" +MEMORY_DIR="$CLAUDE_DIR/projects/${PROJECT_KEY}/memory" MSG="${1:-sync config}" echo "Syncing from ~/.claude ..."