diff --git a/README.md b/README.md index 4f37e51..129c5ad 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ flowchart TB end subgraph Artifacts["đŸ“Ļ Installed Artifacts"] - EXE["/usr/local/bin/luca"] + EXE["~/.local/bin/luca
(default, overridable via INSTALL_DIR)"] HOOK["~/.luca/shell_hook.sh"] GITHOOK[".git/hooks/post-checkout"] RCFILE["~/.bashrc or ~/.zshrc"] @@ -95,9 +95,12 @@ flowchart TD CompareVersion -->|No| Download Download[đŸ“Ĩ Download ZIP from
GitHub releases] --> Extract[đŸ“Ļ Extract ZIP] - Extract --> InstallBin[🚀 Move to /usr/local/bin
chmod +x] + Extract --> InstallBin[🚀 Move to ~/.local/bin
chmod +x] - InstallBin --> SetupHook[🔧 Setup Shell Hook] + InstallBin --> SetupPath{"~/.local/bin
on PATH?"} + SetupPath -->|No| AddPath[🔧 Append PATH export
to RC file] + SetupPath -->|Yes| SetupHook + AddPath --> SetupHook[🔧 Setup Shell Hook] subgraph ShellHookSetup["Shell Hook Setup"] SetupHook --> CreateDir[Create ~/.luca/] @@ -247,7 +250,7 @@ flowchart TD GetVersion --> RemoveExe WarnNoExe --> RemoveExe - RemoveExe[đŸ—‘ī¸ Remove
/usr/local/bin/luca] + RemoveExe[đŸ—‘ī¸ Remove
~/.local/bin/luca] RemoveExe --> DetectShell{Detect shell} DetectShell -->|Bash| UseBashrc[Use ~/.bashrc] @@ -262,8 +265,15 @@ flowchart TD CheckHook -->|Yes| RemoveHook[Remove hook line
from RC file] CheckHook -->|No| InfoNoHook[â„šī¸ No hook found] - RemoveHook --> RemoveDir - InfoNoHook --> RemoveDir + RemoveHook --> CheckPathExport + InfoNoHook --> CheckPathExport + + CheckPathExport{PATH export
in RC file?} + CheckPathExport -->|Yes| RemovePathExport[Remove PATH export
from RC file] + CheckPathExport -->|No| InfoNoPathExport[â„šī¸ No PATH export found] + + RemovePathExport --> RemoveDir + InfoNoPathExport --> RemoveDir RemoveDir{~/.luca/
exists?} RemoveDir -->|Yes| DeleteDir[đŸ—‘ī¸ rm -rf ~/.luca/] @@ -282,7 +292,7 @@ flowchart TD ```mermaid flowchart LR subgraph System["System Locations"] - BIN["/usr/local/bin/"] + BIN["~/.local/bin/
(default, overridable via INSTALL_DIR)"] BIN --> LUCA["luca (executable)"] end @@ -327,7 +337,7 @@ sequenceDiagram Note over U,L: First-time Setup U->>T: curl ... | bash install.sh IS->>IS: Download luca binary - IS->>IS: Install to /usr/local/bin + IS->>IS: Install to ~/.local/bin (no sudo needed) IS->>SH: Download shell_hook.sh SH->>T: Modify ~/.zshrc IS->>PC: Install git hook (if in repo) diff --git a/install.sh b/install.sh index dd17cc1..1e1d0c3 100755 --- a/install.sh +++ b/install.sh @@ -10,7 +10,7 @@ TOOL_NAME="Luca" BIN_NAME="luca" -INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}" +INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}" TOOL_FOLDER=".luca" VERSION_FILE="${PWD}/.luca-version" ORGANIZATION="LucaTools" @@ -248,6 +248,47 @@ sudo_if_install_dir_not_writeable "chmod +x $EXECUTABLE_FILE" echo "✅ $TOOL_NAME ($REQUIRED_EXECUTABLE_VERSION) successfully installed to $INSTALL_DIR" +# ============================================================================= +# PATH SETUP +# ============================================================================= + +# Detect the current shell and its RC file (used here and in the +# "installation complete" summary below) +SHELL_PROFILE="" +case "$SHELL" in +*/bash) + SHELL_PROFILE="$HOME/.bashrc" + ;; +*/zsh) + SHELL_PROFILE="$HOME/.zshrc" + ;; +esac + +PATH_EXPORT_LINE="export PATH=\"$INSTALL_DIR:\$PATH\"" + +# Ensure $INSTALL_DIR is on PATH, both for this session and future ones +case ":$PATH:" in +*":$INSTALL_DIR:"*) + # Already on PATH, nothing to do + ;; +*) + if [ -n "$SHELL_PROFILE" ]; then + if [ ! -f "$SHELL_PROFILE" ] || ! grep -Fq "$PATH_EXPORT_LINE" "$SHELL_PROFILE"; then + echo "🔧 Adding $INSTALL_DIR to PATH in $SHELL_PROFILE" + { + echo "" + echo "# Added by $TOOL_NAME installer to make $BIN_NAME available on PATH" + echo "$PATH_EXPORT_LINE" + } >> "$SHELL_PROFILE" + fi + else + echo "âš ī¸ WARNING: Could not detect shell RC file to add $INSTALL_DIR to PATH." + echo " Please add it manually, e.g.: $PATH_EXPORT_LINE" + fi + export PATH="$INSTALL_DIR:$PATH" + ;; +esac + # ============================================================================= # SHELL HOOK SETUP # ============================================================================= @@ -369,22 +410,11 @@ fi echo "" echo "💡 To start using Luca:" -# Detect the current shell and set the appropriate RC file -SHELL_PROFILE="" - -case "$SHELL" in -*/bash) - SHELL_PROFILE="$HOME/.bashrc" - ;; -*/zsh) - SHELL_PROFILE="$HOME/.zshrc" - ;; -*) +if [ -z "$SHELL_PROFILE" ]; then echo "WARNING: Unsupported shell: $SHELL" echo "Manual setup may be required. Supported shells: bash, zsh" exit 1 - ;; -esac +fi echo " 1. Restart your terminal or run: source $SHELL_PROFILE" echo " 2. Run: $BIN_NAME --help" diff --git a/uninstall.sh b/uninstall.sh index 7a3fa39..8485b4f 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -9,7 +9,7 @@ TOOL_NAME="Luca" BIN_NAME="luca" -INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}" +INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}" TOOL_FOLDER=".luca" TOOL_DIR="$HOME/$TOOL_FOLDER" SHELL_HOOK_SCRIPT_PATH="$TOOL_DIR/shell_hook.sh" @@ -162,6 +162,30 @@ else print_warning "Shell configuration file not found: $SHELL_RC_FILE" fi +# ============================================================================= +# REMOVE PATH EXPORT +# ============================================================================= + +print_header "REMOVING PATH EXPORT" + +PATH_EXPORT_LINE="export PATH=\"$INSTALL_DIR:\$PATH\"" + +if [ -n "$SHELL_RC_FILE" ] && [ -f "$SHELL_RC_FILE" ]; then + if grep -Fq "$PATH_EXPORT_LINE" "$SHELL_RC_FILE"; then + print_info "Found PATH export in $SHELL_RC_FILE, removing..." + + temp_file=$(mktemp) + + grep -v -F "# Added by $TOOL_NAME installer to make $BIN_NAME available on PATH" "$SHELL_RC_FILE" | grep -v -F "$PATH_EXPORT_LINE" > "$temp_file" + + mv "$temp_file" "$SHELL_RC_FILE" + + print_success "PATH export removed from $SHELL_RC_FILE" + else + print_info "No PATH export found in $SHELL_RC_FILE" + fi +fi + # ============================================================================= # REMOVE TOOL DIRECTORY # =============================================================================