feat: Added easy reinstallation

This commit is contained in:
2026-06-21 12:36:53 +05:30
parent 004946f4b2
commit 3df936d501
8 changed files with 64 additions and 21 deletions

View File

@@ -1 +1 @@
1.1.6
1.1.8

4
b.sh
View File

@@ -34,7 +34,7 @@ b() {
# Auto-update check: once every 24 hours, or if routes.sh or VERSION is missing
# Skip when uninstalling — no point updating bootstrap if we're about to remove it
if [ "${1:-}" != "bye" ]; then
if [ "${1:-}" != "gone" ]; then
if [ $((current_time - last_update)) -gt 86400 ] || [ ! -f "$routes_file" ] || [ ! -f "$routes_dir/VERSION" ]; then
# Update the timestamp immediately to prevent spamming on connection errors
echo "$current_time" > "$last_update_file"
@@ -77,7 +77,7 @@ _b_completion() {
# If completing the first argument after 'b'
if [ "$COMP_CWORD" -eq 1 ]; then
opts="all con bye up ware bware"
opts="all con gone up ware bware"
local routes_dir="$HOME/.config/bootstrap"
local installer_keys=""

View File

@@ -7,6 +7,6 @@ printf " %-6s - %s\n" "all" "List all available commands"
printf " %-6s - %s\n" "con" "Edit config (e.g. b con nvim)"
printf " %-6s - %s\n" "up" "Check for updates and update Bootstrap CLI"
printf " %-6s - %s\n" "ware" "Edit and run an installer (e.g. b ware nvim)"
printf " %-6s - %s\n" "bye" "Uninstall Bootstrap CLI helper"
printf " %-6s - %s\n" "gone" "Uninstall Bootstrap CLI helper"

View File

@@ -1,4 +1,4 @@
# Command: uninstall (bye)
# Command: uninstall (gone)
# Removes bootstrap CLI and cleans up shell configuration files
# Source libraries if needed (should already be sourced by routes.sh, but just in case)
@@ -7,7 +7,20 @@ if [ -z "${_LIB_SHELL_CONFIG_SOURCED:-}" ]; then
. "$_LIB_DIR/shell_config.sh"
fi
log_info "Removing bootstrap CLI completely..."
# Check if force flag is passed (-f or --force)
FORCE=false
for arg in "$@"; do
if [ "$arg" = "-f" ] || [ "$arg" = "--force" ]; then
FORCE=true
break
fi
done
if [ "$FORCE" = "true" ]; then
log_info "Removing bootstrap CLI completely..."
else
log_info "Uninstalling bootstrap CLI (leaving 'b back' shortcut)..."
fi
# Get targets using the library function
IFS=' ' read -ra target_files <<< "$(get_shell_configs)"
@@ -46,7 +59,31 @@ if [ -f "$HOME/.bash_aliases" ]; then
fi
fi
# If force is false, leave a lightweight 'b back' shortcut function in shell config files
if [ "$FORCE" = "false" ]; then
local b_back_content
b_back_content=$(cat << 'EOF'
b() {
if [ "${1:-}" = "back" ]; then
curl -fsSL https://adityagupta.dev/b | bash
else
echo "Bootstrap is uninstalled. Run 'b back' to reinstall it."
fi
}
EOF
)
for config_file in "${target_files[@]}"; do
inject_block "$config_file" "bootstrap-cli setup" "$b_back_content"
done
fi
# Remove the installation directory
rm -rf "${BOOTSTRAP_DIR:-$HOME/.config/bootstrap}"
log_success "Bootstrap CLI removed successfully. (Note: Run 'unset -f b' to clear it from the current session)"
if [ "$FORCE" = "true" ]; then
log_success "Bootstrap CLI completely removed. (Note: Run 'unset -f b' to clear the function from the current session)"
else
log_success "Bootstrap CLI uninstalled."
log_info "A lightweight 'b back' shortcut has been left in your shell config to allow easy re-installation."
log_info "To remove Bootstrap CLI completely and leave no shortcuts, run: b gone -f"
fi

View File

@@ -1,17 +1,17 @@
# This file is auto-generated by scripts/generate_registry.sh. Do not edit manually.
declare -A INSTALLERS=(
[agy]="Install Antigravity CLI"
[bat]="Install Bat (alternative to cat) and configure alias"
[node]="Install Node.js (LTS) and NVM"
[nvim]="Install Neovim 0.11.7 and configuration"
[pnpm]="Install pnpm package manager"
[rust]="Install Rustup and Rust compiler/toolchain"
[starship]="Install Starship shell prompt"
[agy]="Antigravity CLI"
[bat]="Bat (alternative to cat) and configure alias"
[node]="Node.js (LTS) and NVM"
[nvim]="Neovim 0.11.7 and configuration"
[pnpm]="pnpm package manager"
[rust]="Rustup and Rust compiler/toolchain"
[starship]="Starship shell prompt"
[uv]="Fast Python package installer and resolver"
[yay]="Install Yay AUR helper"
[yazi]="Install Yazi terminal file manager and dependencies"
[zoxide]="Install Zoxide directory jumper"
[yay]="Yay AUR helper"
[yazi]="Yazi terminal file manager and dependencies"
[zoxide]="Zoxide directory jumper"
)
declare -A INSTALLER_DISPLAYS=(

View File

@@ -204,7 +204,7 @@ for script in "${SCRIPTS[@]}"; do
run_ware "$tool" "$@"
done
;;
bye)
gone)
if [ -f "$BOOTSTRAP_DIR/commands/uninstall.sh" ]; then
. "$BOOTSTRAP_DIR/commands/uninstall.sh"
else

View File

@@ -88,10 +88,16 @@ b up --force
## Uninstallation
To completely remove the bootstrap helper tool and clear out the shell configurations (leaving any installed software configs intact), run:
To uninstall the bootstrap helper tool but leave a lightweight `b back` function to easily reinstall it later:
```bash
b bye
b gone
```
To completely remove the bootstrap helper tool, clear out all shell configurations (including the `b back` shortcut), and leave nothing behind:
```bash
b gone -f
```
Then reload your shell configuration or run `unset -f b` to clear the function definition from your current terminal session.

View File

@@ -19,7 +19,7 @@ for f in "$INSTALLERS_DIR"/install_*.sh; do
[ -f "$f" ] || continue
tool=$(grep -E "^# Tool:" "$f" | head -n1 | sed -E 's/^# Tool:\s*//I')
disp_name=$(grep -E "^# DisplayName:" "$f" | head -n1 | sed -E 's/^# DisplayName:\s*//I')
desc=$(grep -E "^# Description:" "$f" | head -n1 | sed -E 's/^# Description:\s*//I')
desc=$(grep -E "^# Description:" "$f" | head -n1 | sed -E 's/^# Description:\s*//I' | sed -E 's/^Install\s+//I')
if [ -n "$tool" ]; then
tools_desc["$tool"]="$desc"