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:
@@ -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
@@ -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"
|
||||
|
||||
|
||||
@@ -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 ..."
|
||||
|
||||
Reference in New Issue
Block a user