diff --git a/installers/install_nvim.sh b/installers/install_nvim.sh index 82603ba..0808cec 100644 --- a/installers/install_nvim.sh +++ b/installers/install_nvim.sh @@ -1,4 +1,17 @@ #!/usr/bin/env bash +# +# Neovim Installer Script +# +# What this script does: +# 1. Detects the Linux distribution. +# 2. Installs required dependencies (git, wget, tar, curl, unzip, ripgrep, fd, cmake, make, gcc, python, nodejs, npm, xclip, wl-clipboard, fzf). +# 3. Checks whether Neovim 0.11.7 is already installed. +# 4. Prompts before installing or upgrading Neovim. +# 5. Installs the official Neovim binary to /opt/nvim. +# 6. Creates a symlink at /usr/local/bin/nvim. +# 7. Clones the Neovim configuration into ~/.config/nvim. +# 8. Configures shell files (~/.bashrc / ~/.zshrc) to set alias vim="nvim" and export EDITOR="nvim". +# # Run metascript to check if the shell is bash PARENT_DIR="$(dirname "$0")/.." @@ -150,11 +163,41 @@ install_config() { echo "Configuration installed." } +configure_shell() { + local target_files=() + [ -f "$HOME/.bashrc" ] && target_files+=("$HOME/.bashrc") + [ -f "$HOME/.zshrc" ] && target_files+=("$HOME/.zshrc") + + for config_file in "${target_files[@]}"; do + local modified=false + + # Add alias vim=nvim if not present + if ! grep -q "alias vim=" "$config_file" 2>/dev/null; then + echo "Adding alias vim=nvim to $config_file..." + echo 'alias vim="nvim"' >> "$config_file" + modified=true + fi + + # Add export EDITOR=nvim if not present + if ! grep -q "export EDITOR=" "$config_file" 2>/dev/null; then + echo "Setting EDITOR=nvim in $config_file..." + echo 'export EDITOR="nvim"' >> "$config_file" + modified=true + fi + + # Source if modified + if [ "$modified" = true ] && [ "$config_file" = "$HOME/.bashrc" ]; then + . "$config_file" 2>/dev/null || true + fi + done +} + main() { check_config_dir install_packages install_nvim install_config + configure_shell echo echo "Installation complete." diff --git a/installers/install_yazi.sh b/installers/install_yazi.sh index 998acf1..db6e4f2 100755 --- a/installers/install_yazi.sh +++ b/installers/install_yazi.sh @@ -1,4 +1,17 @@ #!/usr/bin/env bash +# +# Yazi Installer Script +# +# What this script does: +# 1. Detects the Linux distribution. +# 2. Prompts before installing or upgrading Yazi. +# 3. Installs Yazi: +# * Arch Linux: Installs yazi via pacman. +# * Debian / Ubuntu: Downloads the latest .deb release package from GitHub and installs it. +# * Fedora: Enables the COPR repository (lihaohong/yazi) and installs yazi (initially skipping weak dependencies). +# 4. Subsequently installs the dependencies (ffmpeg, 7zip / p7zip-full, jq, poppler, fd / fd-find, ripgrep, fzf, zoxide, resvg, imagemagick) to make Yazi available quicker. +# 5. Configures a shell wrapper function 'y' in ~/.bashrc and ~/.zshrc that allows changing directory on exit. +# # Run metascript to check if the shell is bash PARENT_DIR="$(dirname "$0")/.." diff --git a/readme.md b/readme.md index 7a45f8f..9bff598 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,8 @@ The goal is simple: reduce the number of manual steps required after installing | `install_nvim.sh` | Installs Neovim 0.11.7 and clones my Neovim configuration repository. | | `install_yazi.sh` | Installs Yazi terminal file manager and its dependencies. | +All scripts support Arch Linux, Debian / Ubuntu, and Fedora. + More scripts will be added over time. ## Usage @@ -29,36 +31,15 @@ b yazi b nvim,yazi ``` -## What the Neovim Installer Does +## Uninstallation -The Neovim bootstrap script: +To completely remove the bootstrap helper tool and clear out the shell configurations (leaving any installed software configs intact), run: -1. Detects the Linux distribution. -2. Installs required dependencies (`git`, `wget`, `tar`). -3. Checks whether Neovim 0.11.7 is already installed. -4. Prompts before installing or upgrading Neovim. -5. Installs the official Neovim binary to `/opt/nvim`. -6. Creates a symlink at `/usr/local/bin/nvim`. -7. Clones my Neovim configuration into `~/.config/nvim`. +```bash +b bye +``` -## What the Yazi Installer Does - -The Yazi bootstrap script: - -1. Detects the Linux distribution. -2. Prompts before installing or upgrading Yazi. -3. Installs Yazi: - * **Arch Linux**: Installs `yazi` via pacman. - * **Debian / Ubuntu**: Downloads the latest `.deb` release package from GitHub and installs it. - * **Fedora**: Enables the COPR repository (`lihaohong/yazi`) and installs `yazi` (initially skipping weak dependencies). -4. Subsequently installs the dependencies (`ffmpeg`, `7zip` / `p7zip-full`, `jq`, `poppler`, `fd` / `fd-find`, `ripgrep`, `fzf`, `zoxide`, `resvg`, `imagemagick`) to make Yazi available quicker. -5. Configures a shell wrapper function `y` in `~/.bashrc` and `~/.zshrc` that allows changing directory on exit. - -Supported distributions: - -* Arch Linux -* Debian / Ubuntu -* Fedora +Then reload your shell configuration or run `unset -f b` to clear the function definition from your current terminal session. ## Philosophy @@ -73,17 +54,6 @@ That means they may make assumptions about: The scripts are intentionally straightforward Bash scripts that can be inspected and modified before execution. -## Repository Structure - -```text -. -├── bootstrap.sh -├── routes.sh -└── installers/ - ├── install_nvim.sh - └── install_yazi.sh -``` - ## Future Plans Potential additions include: