Make sync scripts cross-platform (Linux + macOS)

Derive the memory project-key from $HOME (replacing / with -) instead of
hardcoding the macOS -Users-<username> path, so install.sh/sync.sh resolve
~/.claude/projects/-home-<user>/memory on Linux and -Users-<user> on macOS.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 11:46:10 +01:00
co-authored by Claude Opus 4.8
parent 98e1b0f09d
commit 2ffbc1ea84
3 changed files with 11 additions and 5 deletions
+3 -2
View File
@@ -41,5 +41,6 @@ git pull
## Memory path
Memory files live at `~/.claude/projects/-Users-<username>/memory/`. The scripts resolve
`<username>` via `whoami` automatically.
Memory files live under `~/.claude/projects/<project-key>/memory/`, where `<project-key>` is
the home directory with `/` replaced by `-`. The scripts derive this from `$HOME` automatically,
so it resolves correctly on macOS (`-Users-<username>`) and Linux (`-home-<username>`).
+4 -1
View File
@@ -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"
+4 -2
View File
@@ -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 ..."