Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ flowchart TB
end

subgraph Artifacts["📦 Installed Artifacts"]
EXE["/usr/local/bin/luca"]
EXE["~/.local/bin/luca<br/>(default, overridable via INSTALL_DIR)"]
HOOK["~/.luca/shell_hook.sh"]
GITHOOK[".git/hooks/post-checkout"]
RCFILE["~/.bashrc or ~/.zshrc"]
Expand Down Expand Up @@ -95,9 +95,12 @@ flowchart TD
CompareVersion -->|No| Download

Download[📥 Download ZIP from<br/>GitHub releases] --> Extract[📦 Extract ZIP]
Extract --> InstallBin[🚀 Move to /usr/local/bin<br/>chmod +x]
Extract --> InstallBin[🚀 Move to ~/.local/bin<br/>chmod +x]

InstallBin --> SetupHook[🔧 Setup Shell Hook]
InstallBin --> SetupPath{"~/.local/bin<br/>on PATH?"}
SetupPath -->|No| AddPath[🔧 Append PATH export<br/>to RC file]
SetupPath -->|Yes| SetupHook
AddPath --> SetupHook[🔧 Setup Shell Hook]

subgraph ShellHookSetup["Shell Hook Setup"]
SetupHook --> CreateDir[Create ~/.luca/]
Expand Down Expand Up @@ -247,7 +250,7 @@ flowchart TD
GetVersion --> RemoveExe
WarnNoExe --> RemoveExe

RemoveExe[🗑️ Remove<br/>/usr/local/bin/luca]
RemoveExe[🗑️ Remove<br/>~/.local/bin/luca]
RemoveExe --> DetectShell{Detect shell}

DetectShell -->|Bash| UseBashrc[Use ~/.bashrc]
Expand All @@ -262,8 +265,15 @@ flowchart TD
CheckHook -->|Yes| RemoveHook[Remove hook line<br/>from RC file]
CheckHook -->|No| InfoNoHook[ℹ️ No hook found]

RemoveHook --> RemoveDir
InfoNoHook --> RemoveDir
RemoveHook --> CheckPathExport
InfoNoHook --> CheckPathExport

CheckPathExport{PATH export<br/>in RC file?}
CheckPathExport -->|Yes| RemovePathExport[Remove PATH export<br/>from RC file]
CheckPathExport -->|No| InfoNoPathExport[ℹ️ No PATH export found]

RemovePathExport --> RemoveDir
InfoNoPathExport --> RemoveDir

RemoveDir{~/.luca/<br/>exists?}
RemoveDir -->|Yes| DeleteDir[🗑️ rm -rf ~/.luca/]
Expand All @@ -282,7 +292,7 @@ flowchart TD
```mermaid
flowchart LR
subgraph System["System Locations"]
BIN["/usr/local/bin/"]
BIN["~/.local/bin/<br/>(default, overridable via INSTALL_DIR)"]
BIN --> LUCA["luca (executable)"]
end

Expand Down Expand Up @@ -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)
Expand Down
58 changes: 44 additions & 14 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
# =============================================================================
Expand Down Expand Up @@ -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"
Expand Down
26 changes: 25 additions & 1 deletion uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
# =============================================================================
Expand Down
Loading