Skip to content

Commit 6079b9a

Browse files
Blazeclaude
andcommitted
Auto-add install dir to PATH in shell config
Instead of just warning, automatically append to ~/.bashrc or ~/.zshrc. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 96f8fd0 commit 6079b9a

1 file changed

Lines changed: 28 additions & 13 deletions

File tree

install.sh

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,36 @@ install() {
102102
info "Binary installed: $INSTALL_DIR/$TARGET_NAME"
103103
}
104104

105-
# Check if install dir is in PATH
105+
# Check if install dir is in PATH and add if needed
106106
check_path() {
107-
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
108-
echo ""
109-
warn "$INSTALL_DIR is not in your PATH"
110-
echo ""
111-
echo "Add it to your shell config:"
112-
echo ""
113-
echo -e " ${CYAN}# For bash (~/.bashrc)${NC}"
114-
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
115-
echo ""
116-
echo -e " ${CYAN}# For zsh (~/.zshrc)${NC}"
117-
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
118-
echo ""
107+
if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
108+
return 0
109+
fi
110+
111+
# Determine shell config file
112+
local shell_rc=""
113+
if [ -n "$ZSH_VERSION" ] || [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/usr/bin/zsh" ]; then
114+
shell_rc="$HOME/.zshrc"
115+
else
116+
shell_rc="$HOME/.bashrc"
117+
fi
118+
119+
local path_line="export PATH=\"\$PATH:$INSTALL_DIR\""
120+
121+
# Check if already in config (maybe PATH just not reloaded)
122+
if [ -f "$shell_rc" ] && grep -q "$INSTALL_DIR" "$shell_rc" 2>/dev/null; then
123+
info "$INSTALL_DIR already in $shell_rc (restart shell to apply)"
124+
return 0
119125
fi
126+
127+
# Add to shell config
128+
echo "" >> "$shell_rc"
129+
echo "# Added by claude-tasks installer" >> "$shell_rc"
130+
echo "$path_line" >> "$shell_rc"
131+
info "Added $INSTALL_DIR to PATH in $shell_rc"
132+
133+
# Also export for current session
134+
export PATH="$PATH:$INSTALL_DIR"
120135
}
121136

122137
# Setup Sprite service (if running on Sprite)

0 commit comments

Comments
 (0)