# Per-repo Claude Code login: a `.claude-config-dir` marker at (or above) the # cwd names a config dir; while inside that tree CLAUDE_CONFIG_DIR points at # $HOME/.claude- (or an absolute path if the marker holds one), so # `claude` and `dev-launch claude` both pick up that login. Leaving the tree # restores whatever was set before. Sourced from ~/.zshrc. _claude_config_dir_apply() { local dir="$PWD" marker="" name="" while [[ "$dir" != "/" && -n "$dir" ]]; do if [[ -f "$dir/.claude-config-dir" ]]; then marker="$dir/.claude-config-dir"; break; fi dir="${dir:h}" done if [[ -z "$marker" ]]; then if [[ -n "${_CLAUDE_CONFIG_DIR_BY_HOOK:-}" ]]; then if [[ -n "${_CLAUDE_CONFIG_DIR_PREV:-}" ]]; then export CLAUDE_CONFIG_DIR="$_CLAUDE_CONFIG_DIR_PREV"; else unset CLAUDE_CONFIG_DIR; fi unset _CLAUDE_CONFIG_DIR_BY_HOOK _CLAUDE_CONFIG_DIR_PREV fi return fi name="$(<"$marker")"; name="${name//[[:space:]]/}" [[ -z "$name" ]] && return local target if [[ "$name" == /* ]]; then target="$name"; else target="$HOME/.claude-$name"; fi if [[ -z "${_CLAUDE_CONFIG_DIR_BY_HOOK:-}" ]]; then _CLAUDE_CONFIG_DIR_PREV="${CLAUDE_CONFIG_DIR:-}"; fi _CLAUDE_CONFIG_DIR_BY_HOOK=1 export CLAUDE_CONFIG_DIR="$target" [[ -d "$target" ]] || print -u2 "claude-config-dir: $target does not exist yet — run: claude-config-dir-init $target" } autoload -Uz add-zsh-hook add-zsh-hook chpwd _claude_config_dir_apply _claude_config_dir_apply