From 7981c13dc9b6a545ed9670fba6072533436e8810 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Tue, 8 Jul 2025 08:26:33 -0600 Subject: [PATCH 1/4] feat: enhance Docker setup for Linux compatibility with dynamic user permissions closes #18 --- Dockerfile | 164 ++++++++++++++++++++++++++-------- Makefile | 7 ++ docker-compose.yml | 2 + scripts/build.sh | 11 ++- scripts/detect-permissions.sh | 34 +++++++ 5 files changed, 178 insertions(+), 40 deletions(-) create mode 100755 scripts/detect-permissions.sh diff --git a/Dockerfile b/Dockerfile index 56bc9b9..b3d9ec9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,59 +38,147 @@ ENV TZ=$TIMEZONE RUN cp /usr/share/zoneinfo/$TIMEZONE /etc/localtime && \ echo $TIMEZONE > /etc/timezone -#* Create a new user 'developer' with home directory and grant sudo privileges -RUN adduser -D -s /bin/zsh developer && \ - echo "developer ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers - -#* Switch to the 'developer' user for the rest of the setup -USER developer -WORKDIR /home/developer - -#* Install Oh My Zsh for the 'developer' user -RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" || true +#* Create a developer user with dynamic UID/GID for Linux compatibility +ARG USER_UID=1000 +ARG USER_GID=1000 +RUN set -eux; \ + echo "Setting up user with UID: $USER_UID, GID: $USER_GID"; \ + # Handle group creation/selection + if getent group $USER_GID >/dev/null 2>&1; then \ + GROUP_NAME=$(getent group $USER_GID | cut -d: -f1); \ + echo "Using existing group: $GROUP_NAME (GID: $USER_GID)"; \ + else \ + # Check if developer group exists with different GID + if getent group developer >/dev/null 2>&1; then \ + # Remove existing developer group if it has different GID + delgroup developer || true; \ + fi; \ + addgroup -g $USER_GID developer; \ + GROUP_NAME="developer"; \ + echo "Created group: $GROUP_NAME (GID: $USER_GID)"; \ + fi; \ + # Handle user creation/modification + if getent passwd $USER_UID >/dev/null 2>&1; then \ + # User with this UID already exists + EXISTING_USER=$(getent passwd $USER_UID | cut -d: -f1); \ + echo "User with UID $USER_UID already exists: $EXISTING_USER"; \ + # Change the user's primary group to our target group + sed -i "s/^$EXISTING_USER:\([^:]*\):\([^:]*\):\([^:]*\):/$EXISTING_USER:\1:\2:$USER_GID:/" /etc/passwd; \ + # Ensure the user has zsh shell + sed -i "s|^$EXISTING_USER:\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\(.*\)|$EXISTING_USER:\1:\2:\3:\4:\5:/bin/zsh|" /etc/passwd; \ + # Add to sudoers if not already there + if ! grep -q "^$EXISTING_USER " /etc/sudoers; then \ + echo "$EXISTING_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; \ + fi; \ + # Get user's home directory and set environment variable + USER_HOME=$(getent passwd $EXISTING_USER | cut -d: -f6); \ + echo "export USER_HOME=$USER_HOME" >> /etc/environment; \ + # Create developer symlink if the user isn't named developer + if [ "$EXISTING_USER" != "developer" ]; then \ + # Create symlink for compatibility + if [ ! -e /home/developer ]; then \ + ln -sf $USER_HOME /home/developer; \ + fi; \ + fi; \ + echo "Using existing user: $EXISTING_USER with home: $USER_HOME"; \ + else \ + # No user with this UID, create new developer user + # First, remove any existing developer user with different UID + if getent passwd developer >/dev/null 2>&1; then \ + deluser developer || true; \ + fi; \ + # Create the developer user + adduser -D -u $USER_UID -G $GROUP_NAME -s /bin/zsh developer; \ + echo "Created user: developer (UID: $USER_UID, GID: $USER_GID)"; \ + echo "developer ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; \ + fi + +#* Switch to the developer user for the rest of the setup +USER $USER_UID:$USER_GID + +#* Determine the actual home directory and set up environment +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + echo "Working with home directory: $USER_HOME" && \ + # Ensure the home directory exists and has proper permissions + mkdir -p $USER_HOME && \ + chown $USER_UID:$USER_GID $USER_HOME + +#* Set dynamic WORKDIR based on actual user home +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + echo "Setting working directory to: $USER_HOME" +WORKDIR /home/node + +#* Install Oh My Zsh for the current user +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + cd $USER_HOME && \ + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" || true #* Install useful zsh plugins -RUN git clone https://github.com/zsh-users/zsh-autosuggestions /home/developer/.oh-my-zsh/custom/plugins/zsh-autosuggestions && \ - git clone https://github.com/zsh-users/zsh-syntax-highlighting /home/developer/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && \ - git clone https://github.com/zsh-users/zsh-completions /home/developer/.oh-my-zsh/custom/plugins/zsh-completions && \ - sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions)/' /home/developer/.zshrc +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + mkdir -p $USER_HOME/.oh-my-zsh/custom/plugins && \ + git clone https://github.com/zsh-users/zsh-autosuggestions $USER_HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions && \ + git clone https://github.com/zsh-users/zsh-syntax-highlighting $USER_HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && \ + git clone https://github.com/zsh-users/zsh-completions $USER_HOME/.oh-my-zsh/custom/plugins/zsh-completions && \ + sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions)/' $USER_HOME/.zshrc #* Install the Powerlevel10k theme -RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /home/developer/.oh-my-zsh/custom/themes/powerlevel10k && \ - sed -i 's/ZSH_THEME=".*"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' /home/developer/.zshrc +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + mkdir -p $USER_HOME/.oh-my-zsh/custom/themes && \ + git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $USER_HOME/.oh-my-zsh/custom/themes/powerlevel10k && \ + sed -i 's/ZSH_THEME=".*"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' $USER_HOME/.zshrc -#* Clone LazyVim for the 'developer' user -RUN git clone https://github.com/LazyVim/starter /home/developer/.config/nvim +#* Clone LazyVim for the current user +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + mkdir -p $USER_HOME/.config && \ + git clone https://github.com/LazyVim/starter $USER_HOME/.config/nvim #* Remove the .git folder, so you can add it to your own repo later -RUN rm -rf /home/developer/.config/nvim/.git +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + rm -rf $USER_HOME/.config/nvim/.git #* Create useful aliases in .zshrc -RUN echo 'alias ll="exa -la"' >> /home/developer/.zshrc && \ - echo 'alias cat="bat"' >> /home/developer/.zshrc && \ - echo 'alias find="fd"' >> /home/developer/.zshrc && \ - echo 'alias vim="nvim"' >> /home/developer/.zshrc && \ - echo 'alias vi="nvim"' >> /home/developer/.zshrc && \ - echo 'alias lg="lazygit"' >> /home/developer/.zshrc +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + echo 'alias ll="exa -la"' >> $USER_HOME/.zshrc && \ + echo 'alias cat="bat"' >> $USER_HOME/.zshrc && \ + echo 'alias find="fd"' >> $USER_HOME/.zshrc && \ + echo 'alias vim="nvim"' >> $USER_HOME/.zshrc && \ + echo 'alias vi="nvim"' >> $USER_HOME/.zshrc && \ + echo 'alias lg="lazygit"' >> $USER_HOME/.zshrc #* Add helpful environment variables -RUN echo 'export EDITOR=nvim' >> /home/developer/.zshrc && \ - echo 'export VISUAL=nvim' >> /home/developer/.zshrc && \ - echo 'export PAGER=bat' >> /home/developer/.zshrc +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + echo 'export EDITOR=nvim' >> $USER_HOME/.zshrc && \ + echo 'export VISUAL=nvim' >> $USER_HOME/.zshrc && \ + echo 'export PAGER=bat' >> $USER_HOME/.zshrc + +#* Configure Powerlevel10k to avoid gitstatus issues +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + echo 'POWERLEVEL9K_DISABLE_GITSTATUS=true' >> $USER_HOME/.zshrc && \ + echo 'POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true' >> $USER_HOME/.zshrc && \ + echo 'typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet' >> $USER_HOME/.zshrc #* Switch back to root to fix permissions and create directories USER root -#* Create cache directories and ensure proper permissions -RUN mkdir -p /home/developer/.cache/nvim /home/developer/.cache/zsh /home/developer/.cache/pip \ - /home/developer/.local/share/nvim /home/developer/.local/state/nvim && \ - chown -R developer:developer /home/developer - -#* Switch back to developer user -USER developer - -#* Set the default working directory -WORKDIR /home/developer +#* Create cache directories and ensure proper permissions for the actual user home +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && \ + echo "Creating cache directories in: $USER_HOME" && \ + mkdir -p $USER_HOME/.cache/nvim $USER_HOME/.cache/zsh $USER_HOME/.cache/pip \ + $USER_HOME/.local/share/nvim $USER_HOME/.local/state/nvim \ + $USER_HOME/.cache/gitstatus $USER_HOME/.cache/p10k && \ + chown -R $USER_UID:$USER_GID $USER_HOME && \ + chmod -R 755 $USER_HOME/.cache $USER_HOME/.local && \ + # Also ensure the developer symlink has proper permissions if it exists + if [ -L /home/developer ]; then \ + chown -h $USER_UID:$USER_GID /home/developer; \ + fi + +#* Switch back to the container user +USER $USER_UID:$USER_GID + +#* Set the default working directory to the actual user home +RUN USER_HOME=$(getent passwd $USER_UID | cut -d: -f6) && echo "Final working directory: $USER_HOME" +WORKDIR /home/node #* Set the default shell to Zsh CMD ["/bin/zsh"] \ No newline at end of file diff --git a/Makefile b/Makefile index c1728da..8fbcdab 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,13 @@ VERSION := $(shell cat VERSION 2>/dev/null || echo "1.0.0") CONTAINER_NAME := lazyvim COMPOSE_FILE := docker-compose.yml +# Detect user permissions for Linux compatibility +USER_UID := $(shell if [ "$(shell uname)" = "Linux" ]; then id -u; else echo "1000"; fi) +USER_GID := $(shell if [ "$(shell uname)" = "Linux" ]; then id -g; else echo "1000"; fi) + +# Docker compose with environment variables for Linux permission compatibility +DOCKER_COMPOSE := USER_UID=$(USER_UID) USER_GID=$(USER_GID) docker compose + help: ## Show this help message @echo "$(BLUE)LazyVim Docker Environment - Available Commands$(NC)" @echo "" diff --git a/docker-compose.yml b/docker-compose.yml index 1e8dd96..9a14ec4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,8 @@ services: args: VERSION: ${VERSION:-1.0.0} TIMEZONE: America/Mexico_City + USER_UID: ${USER_UID:-1000} + USER_GID: ${USER_GID:-1000} container_name: lazyvim hostname: lazyvim-dev restart: unless-stopped diff --git a/scripts/build.sh b/scripts/build.sh index c244b46..ab26a83 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -20,6 +20,9 @@ VERSION_FILE="VERSION" CONTAINER_NAME="lazyvim" DOTFILES_DIR=".dotfiles" +# Source permission detection +source "$(dirname "$0")/detect-permissions.sh" + # Functions log_info() { printf "${BLUE}[INFO]${NC} %s\n" "$1" @@ -47,8 +50,12 @@ VERSION=$(cat "$VERSION_FILE") # Get timezone from docker-compose.yml TIMEZONE=$(grep -A 10 "args:" docker-compose.yml | grep "TIMEZONE:" | awk '{print $2}' || echo "America/Mexico_City") +# Detect and configure user permissions +detect_user_permissions + log_info "Building LazyVim Docker environment v$VERSION" log_info "Timezone: $TIMEZONE" +log_info "User permissions: UID=$USER_UID, GID=$USER_GID" # Create .dotfiles directory if it doesn't exist if [[ ! -d "$DOTFILES_DIR" ]]; then @@ -72,7 +79,7 @@ docker compose pull || log_warning "Could not pull some images, continuing..." # Build the container log_info "Building container with version $VERSION..." -if docker compose build --build-arg VERSION="$VERSION" --no-cache; then +if USER_UID=$USER_UID USER_GID=$USER_GID docker compose build --build-arg VERSION="$VERSION" --build-arg USER_UID="$USER_UID" --build-arg USER_GID="$USER_GID" --no-cache; then log_success "Container built successfully" else log_error "Failed to build container" @@ -81,7 +88,7 @@ fi # Start the container log_info "Starting the container..." -if docker compose up --force-recreate -d; then +if USER_UID=$USER_UID USER_GID=$USER_GID docker compose up --force-recreate -d; then log_success "Container started successfully" else log_error "Failed to start container" diff --git a/scripts/detect-permissions.sh b/scripts/detect-permissions.sh new file mode 100755 index 0000000..3894533 --- /dev/null +++ b/scripts/detect-permissions.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# LazyVim Docker - User Permissions Detection +# This script detects the appropriate UID/GID for the current system +# to ensure proper file permissions inside the Docker container + +detect_user_permissions() { + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + # Linux - use current user's UID/GID to avoid permission issues + export USER_UID=$(id -u) + export USER_GID=$(id -g) + if [[ -n "${SUDO_UID:-}" ]] && [[ -n "${SUDO_GID:-}" ]]; then + # If running with sudo, use the original user's UID/GID + export USER_UID=$SUDO_UID + export USER_GID=$SUDO_GID + fi + echo "[INFO] Linux detected - Using UID:GID $USER_UID:$USER_GID for permission compatibility" + else + # macOS/Windows - use default (Docker Desktop handles this automatically) + export USER_UID=1000 + export USER_GID=1000 + echo "[INFO] macOS/Windows detected - Using default UID:GID (Docker Desktop handles permissions)" + fi +} + +# Export the function so it can be sourced by other scripts +export -f detect_user_permissions + +# If script is run directly, just detect and show the permissions +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + detect_user_permissions + echo "USER_UID=$USER_UID" + echo "USER_GID=$USER_GID" +fi From 372057934107a267fba3b607330d8e9ce98c4cd6 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Tue, 8 Jul 2025 16:16:18 -0600 Subject: [PATCH 2/4] refactor: replace echo with printf for consistent output formatting across scripts --- scripts/build.sh | 2 +- scripts/configure.sh | 12 +- scripts/destroy.sh | 10 +- scripts/detect-permissions.sh | 8 +- scripts/health-check.sh | 2 +- scripts/init.sh | 4 +- scripts/install-global-commands.sh | 162 +++++++++++++-------------- scripts/remote-uninstall.sh | 52 ++++----- scripts/remote-update.sh | 38 +++---- scripts/setup.sh | 68 +++++------ scripts/start.sh | 86 +++++++------- scripts/uninstall-global-commands.sh | 14 +-- 12 files changed, 229 insertions(+), 229 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index ab26a83..0480202 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -48,7 +48,7 @@ fi VERSION=$(cat "$VERSION_FILE") # Get timezone from docker-compose.yml -TIMEZONE=$(grep -A 10 "args:" docker-compose.yml | grep "TIMEZONE:" | awk '{print $2}' || echo "America/Mexico_City") +TIMEZONE=$(grep -A 10 "args:" docker-compose.yml | grep "TIMEZONE:" | awk '{print $2}' || printf "America/Mexico_City") # Detect and configure user permissions detect_user_permissions diff --git a/scripts/configure.sh b/scripts/configure.sh index 5debaba..db81a59 100755 --- a/scripts/configure.sh +++ b/scripts/configure.sh @@ -201,7 +201,7 @@ get_current_mounts() { export CURRENT_MOUNTS_DATA="${mounts_data[*]}" # Return 0 always to avoid script termination - echo "$((counter - 1))" > /tmp/mount_count + printf "%d\n" "$((counter - 1))" > /tmp/mount_count return 0 } @@ -322,15 +322,15 @@ configure_timezone() { # Detect system timezone local system_tz="" if command -v timedatectl >/dev/null 2>&1; then - system_tz=$(timedatectl show --property=Timezone --value 2>/dev/null || echo "") + system_tz=$(timedatectl show --property=Timezone --value 2>/dev/null || printf "") elif [[ -f /etc/timezone ]]; then - system_tz=$(cat /etc/timezone 2>/dev/null || echo "") + system_tz=$(cat /etc/timezone 2>/dev/null || printf "") elif [[ "$OSTYPE" == "darwin"* ]]; then - system_tz=$(ls -la /etc/localtime 2>/dev/null | sed 's/.*zoneinfo\///' || echo "") + system_tz=$(ls -la /etc/localtime 2>/dev/null | sed 's/.*zoneinfo\///' || printf "") fi # Get current timezone from docker-compose.yml - local current_tz=$(grep "TIMEZONE:" docker-compose.yml | awk '{print $2}' 2>/dev/null || echo "") + local current_tz=$(grep "TIMEZONE:" docker-compose.yml | awk '{print $2}' 2>/dev/null || printf "") local default_tz="${system_tz:-America/Mexico_City}" printf "๐ŸŒ Timezone Configuration:\n" @@ -564,7 +564,7 @@ configure_additional_directories() { # Get and show numbered list get_current_mounts "true" - local mount_count=$(cat /tmp/mount_count 2>/dev/null || echo "0") + local mount_count=$(cat /tmp/mount_count 2>/dev/null || printf "0") if [[ "$mount_count" -eq 0 ]]; then printf "\n" diff --git a/scripts/destroy.sh b/scripts/destroy.sh index 9ed44e5..18c627a 100755 --- a/scripts/destroy.sh +++ b/scripts/destroy.sh @@ -38,12 +38,12 @@ log_error() { # Confirmation prompt log_warning "This will completely destroy the LazyVim Docker environment!" log_warning "This includes:" -echo " - Stopping and removing containers" -echo " - Removing Docker images" -echo " - Removing Docker volumes (configuration will be lost!)" -echo "" +printf " - Stopping and removing containers\n" +printf " - Removing Docker images\n" +printf " - Removing Docker volumes (configuration will be lost!)\n" +printf "\n" read -p "Are you sure you want to continue? (y/N): " -n 1 -r -echo +printf "\n" if [[ ! $REPLY =~ ^[Yy]$ ]]; then log_info "Operation cancelled" diff --git a/scripts/detect-permissions.sh b/scripts/detect-permissions.sh index 3894533..eebb538 100755 --- a/scripts/detect-permissions.sh +++ b/scripts/detect-permissions.sh @@ -14,12 +14,12 @@ detect_user_permissions() { export USER_UID=$SUDO_UID export USER_GID=$SUDO_GID fi - echo "[INFO] Linux detected - Using UID:GID $USER_UID:$USER_GID for permission compatibility" + printf "[INFO] Linux detected - Using UID:GID %s:%s for permission compatibility\n" "$USER_UID" "$USER_GID" else # macOS/Windows - use default (Docker Desktop handles this automatically) export USER_UID=1000 export USER_GID=1000 - echo "[INFO] macOS/Windows detected - Using default UID:GID (Docker Desktop handles permissions)" + printf "[INFO] macOS/Windows detected - Using default UID:GID (Docker Desktop handles permissions)\n" fi } @@ -29,6 +29,6 @@ export -f detect_user_permissions # If script is run directly, just detect and show the permissions if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then detect_user_permissions - echo "USER_UID=$USER_UID" - echo "USER_GID=$USER_GID" + printf "USER_UID=%s\n" "$USER_UID" + printf "USER_GID=%s\n" "$USER_GID" fi diff --git a/scripts/health-check.sh b/scripts/health-check.sh index 07ab90b..830cc16 100755 --- a/scripts/health-check.sh +++ b/scripts/health-check.sh @@ -108,7 +108,7 @@ health_check() { VOLUMES=$(docker volume ls | grep lazyvim || true) if [[ -n "$VOLUMES" ]]; then log_success "LazyVim volumes found:" - echo "$VOLUMES" | sed 's/^/ /' + printf "%s\n" "$VOLUMES" | sed 's/^/ /' else log_warning "No LazyVim volumes found" fi diff --git a/scripts/init.sh b/scripts/init.sh index ac11264..5351d52 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -42,12 +42,12 @@ if ! docker info >/dev/null 2>&1; then fi # Check if container exists and its state -CONTAINER_STATE=$(docker inspect "$CONTAINER_NAME" 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || echo "missing") +CONTAINER_STATE=$(docker inspect "$CONTAINER_NAME" 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || printf "missing") if [ "$CONTAINER_STATE" = "missing" ]; then log_warning "Container not found. You may need to build it first." read -p "Do you want to build the environment? (y/N): " -n 1 -r - echo + printf "\n" if [[ $REPLY =~ ^[Yy]$ ]]; then log_info "Building environment..." ./scripts/build.sh diff --git a/scripts/install-global-commands.sh b/scripts/install-global-commands.sh index 01d1ae6..ed21191 100755 --- a/scripts/install-global-commands.sh +++ b/scripts/install-global-commands.sh @@ -35,17 +35,17 @@ LAZYVIM_DOCKER_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" LAZYVIM_DOCKER_PATH="$(dirname "$LAZYVIM_DOCKER_PATH")" log_info "LazyVim Docker Global Commands Installer" -echo "" +printf "\n" log_info "This will install global 'lazy' commands that you can use from anywhere:" -echo " lazy start -> make start" -echo " lazy enter -> make enter" -echo " lazy stop -> make stop" -echo " lazy status -> make status" -echo " lazy build -> make build" -echo " lazy health -> make health" -echo " lazy help -> make help" -echo " lazy uninstall -> Complete removal (same as curl method)" -echo "" +printf " lazy start -> make start\n" +printf " lazy enter -> make enter\n" +printf " lazy stop -> make stop\n" +printf " lazy status -> make status\n" +printf " lazy build -> make build\n" +printf " lazy health -> make health\n" +printf " lazy help -> make help\n" +printf " lazy uninstall -> Complete removal (same as curl method)\n" +printf "\n" # Check if we're in the correct directory if [[ ! -f "$LAZYVIM_DOCKER_PATH/Makefile" ]] || [[ ! -f "$LAZYVIM_DOCKER_PATH/docker-compose.yml" ]]; then @@ -81,31 +81,31 @@ lazyvim_docker_path="$LAZYVIM_DOCKER_PATH" lazy() { if [[ \$# -eq 0 ]]; then - echo "LazyVim Docker - Global Commands" - echo "" - echo "Usage: lazy " - echo "" - echo "Available commands:" - echo " help Show all available commands" - echo " start Start the container" - echo " enter Enter the container (starts if stopped)" - echo " stop Stop the container" - echo " status Show container status" - echo " health Run health diagnostics" - echo " build Build/rebuild the container" - echo " restart Restart the container" - echo " destroy Destroy everything" - echo " clean Clean up Docker resources" - echo " quick Quick start (build + enter)" - echo " logs Show container logs" - echo " backup Backup configurations" - echo " version Show version" - echo " configure Reconfigure directories and timezone" - echo " uninstall Complete removal (same as curl method)" - echo "" - echo "Examples:" - echo " lazy enter # Enter LazyVim from anywhere" - echo " lazy build # Build the environment" + printf "LazyVim Docker - Global Commands\n" + printf "\n" + printf "Usage: lazy \n" + printf "\n" + printf "Available commands:\n" + printf " help Show all available commands\n" + printf " start Start the container\n" + printf " enter Enter the container (starts if stopped)\n" + printf " stop Stop the container\n" + printf " status Show container status\n" + printf " health Run health diagnostics\n" + printf " build Build/rebuild the container\n" + printf " restart Restart the container\n" + printf " destroy Destroy everything\n" + printf " clean Clean up Docker resources\n" + printf " quick Quick start (build + enter)\n" + printf " logs Show container logs\n" + printf " backup Backup configurations\n" + printf " version Show version\n" + printf " configure Reconfigure directories and timezone\n" + printf " uninstall Complete removal (same as curl method)\n" + printf "\n" + printf "Examples:\n" + printf " lazy enter # Enter LazyVim from anywhere\n" + printf " lazy build # Build the environment\n" return 0 fi @@ -114,16 +114,16 @@ lazy() { case "\$cmd" in help|start|enter|stop|status|health|build|restart|destroy|clean|quick|logs|backup|configure|version) - echo "๐Ÿš€ Running: make \$cmd \$@" + printf "๐Ÿš€ Running: make %s %s\n" "\$cmd" "\$@" (cd "\$lazyvim_docker_path" && make "\$cmd" "\$@") ;; uninstall) - echo "๐Ÿ—‘๏ธ Running complete uninstaller..." + printf "๐Ÿ—‘๏ธ Running complete uninstaller...\n" (cd "\$lazyvim_docker_path" && ./scripts/remote-uninstall.sh) ;; *) - echo "โŒ Unknown command: \$cmd" - echo "๐Ÿ’ก Use 'lazy' to see available commands" + printf "โŒ Unknown command: %s\n" "\$cmd" + printf "๐Ÿ’ก Use 'lazy' to see available commands\n" return 1 ;; esac @@ -170,31 +170,31 @@ lazyvim_docker_path="$LAZYVIM_DOCKER_PATH" lazy() { if [[ \$# -eq 0 ]]; then - echo "LazyVim Docker - Global Commands" - echo "" - echo "Usage: lazy " - echo "" - echo "Available commands:" - echo " help Show all available commands" - echo " start Start the container" - echo " enter Enter the container (starts if stopped)" - echo " stop Stop the container" - echo " status Show container status" - echo " health Run health diagnostics" - echo " build Build/rebuild the container" - echo " restart Restart the container" - echo " destroy Destroy everything" - echo " clean Clean up Docker resources" - echo " quick Quick start (build + enter)" - echo " logs Show container logs" - echo " backup Backup configurations" - echo " version Show version" - echo " configure Reconfigure directories and timezone" - echo " uninstall Complete removal (same as curl method)" - echo "" - echo "Examples:" - echo " lazy enter # Enter LazyVim from anywhere" - echo " lazy build # Build the environment" + printf "LazyVim Docker - Global Commands\n" + printf "\n" + printf "Usage: lazy \n" + printf "\n" + printf "Available commands:\n" + printf " help Show all available commands\n" + printf " start Start the container\n" + printf " enter Enter the container (starts if stopped)\n" + printf " stop Stop the container\n" + printf " status Show container status\n" + printf " health Run health diagnostics\n" + printf " build Build/rebuild the container\n" + printf " restart Restart the container\n" + printf " destroy Destroy everything\n" + printf " clean Clean up Docker resources\n" + printf " quick Quick start (build + enter)\n" + printf " logs Show container logs\n" + printf " backup Backup configurations\n" + printf " version Show version\n" + printf " configure Reconfigure directories and timezone\n" + printf " uninstall Complete removal (same as curl method)\n" + printf "\n" + printf "Examples:\n" + printf " lazy enter # Enter LazyVim from anywhere\n" + printf " lazy build # Build the environment\n" return 0 fi @@ -203,16 +203,16 @@ lazy() { case "\$cmd" in help|start|enter|stop|status|health|build|restart|destroy|clean|quick|logs|backup|configure|version) - echo "๐Ÿš€ Running: make \$cmd \$@" + printf "๐Ÿš€ Running: make %s %s\n" "\$cmd" "\$@" (cd "\$lazyvim_docker_path" && make "\$cmd" "\$@") ;; uninstall) - echo "๐Ÿ—‘๏ธ Running complete uninstaller..." + printf "๐Ÿ—‘๏ธ Running complete uninstaller...\n" (cd "\$lazyvim_docker_path" && ./scripts/remote-uninstall.sh) ;; *) - echo "โŒ Unknown command: \$cmd" - echo "๐Ÿ’ก Use 'lazy' to see available commands" + printf "โŒ Unknown command: %s\n" "\$cmd" + printf "๐Ÿ’ก Use 'lazy' to see available commands\n" return 1 ;; esac @@ -243,22 +243,22 @@ install_global_commands() { install_bash install_zsh - echo "" + printf "\n" log_success "โœ“ Global 'lazy' commands installed!" - echo "" + printf "\n" log_info "Commands installed for both Bash and Zsh:" - echo " โ€ข Bash: $HOME/.bashrc" - echo " โ€ข Zsh: $HOME/.zshrc" - echo "" + printf " โ€ข Bash: %s/.bashrc\n" "$HOME" + printf " โ€ข Zsh: %s/.zshrc\n" "$HOME" + printf "\n" log_info "Usage:" - echo " lazy enter # Enter LazyVim development environment" - echo " lazy help # Show all available commands" - echo "" + printf " lazy enter # Enter LazyVim development environment\n" + printf " lazy help # Show all available commands\n" + printf "\n" log_info "To activate:" - echo " โ€ข Restart your terminal, or" - echo " โ€ข Run: source ~/.bashrc (for Bash)" - echo " โ€ข Run: source ~/.zshrc (for Zsh)" - echo "" + printf " โ€ข Restart your terminal, or\n" + printf " โ€ข Run: source ~/.bashrc (for Bash)\n" + printf " โ€ข Run: source ~/.zshrc (for Zsh)\n" + printf "\n" # Detect current shell and provide specific activation command local current_shell="" @@ -276,7 +276,7 @@ install_global_commands() { printf "${GREEN}For your current Bash session, run: source ~/.bashrc${NC}\n" fi - echo "" + printf "\n" } # Run the installation diff --git a/scripts/remote-uninstall.sh b/scripts/remote-uninstall.sh index 154cdb1..3b13edb 100755 --- a/scripts/remote-uninstall.sh +++ b/scripts/remote-uninstall.sh @@ -7,13 +7,13 @@ set -e # Colors for output using tput (more compatible) if command -v tput >/dev/null 2>&1 && [[ -t 1 ]]; then - RED=$(tput setaf 1 2>/dev/null || echo '') - GREEN=$(tput setaf 2 2>/dev/null || echo '') - YELLOW=$(tput setaf 3 2>/dev/null || echo '') - BLUE=$(tput setaf 4 2>/dev/null || echo '') - PURPLE=$(tput setaf 5 2>/dev/null || echo '') - CYAN=$(tput setaf 6 2>/dev/null || echo '') - NC=$(tput sgr0 2>/dev/null || echo '') + RED=$(tput setaf 1 2>/dev/null || printf '') + GREEN=$(tput setaf 2 2>/dev/null || printf '') + YELLOW=$(tput setaf 3 2>/dev/null || printf '') + BLUE=$(tput setaf 4 2>/dev/null || printf '') + PURPLE=$(tput setaf 5 2>/dev/null || printf '') + CYAN=$(tput setaf 6 2>/dev/null || printf '') + NC=$(tput sgr0 2>/dev/null || printf '') else RED='' GREEN='' @@ -78,21 +78,21 @@ restart_terminal() { local helper_script="/tmp/lazyvim_cleanup_terminal.sh" cat > "$helper_script" << 'EOF' #!/bin/bash -echo "๐Ÿงน Restarting terminal to complete LazyVim Docker cleanup..." -echo "" +printf "๐Ÿงน Restarting terminal to complete LazyVim Docker cleanup...\n" +printf "\n" EOF - echo "exec $current_shell" >> "$helper_script" + printf "exec %s\n" "$current_shell" >> "$helper_script" chmod +x "$helper_script" - echo "" + printf "\n" print_warning "๐Ÿงน To complete cleanup and remove any traces:" - echo "" + printf "\n" printf " ${GREEN}Option 1 (Easiest):${NC}\n" printf " ${GREEN}%s${NC}\n" "$helper_script" - echo "" + printf "\n" printf " ${GREEN}Option 2 (Manual):${NC}\n" printf " ${GREEN}exec %s${NC}\n" "$current_shell" - echo "" + printf "\n" print_info "๐Ÿ’ก Copy and paste the first command to clean your terminal" print_info "This ensures no traces of 'lazy' commands remain" } @@ -227,13 +227,13 @@ remove_path_modifications() { # Confirm uninstallation # Confirm uninstallation confirm_uninstall() { - echo "" + printf "\n" print_warning "This will completely remove LazyVim Docker from your system:" - echo " โ€ข Docker containers and images" - echo " โ€ข Installation directory ($INSTALL_DIR)" - echo " โ€ข Global 'lazy' command" - echo " โ€ข All data and configurations" - echo "" + printf " โ€ข Docker containers and images\n" + printf " โ€ข Installation directory (%s)\n" "$INSTALL_DIR" + printf " โ€ข Global 'lazy' command\n" + printf " โ€ข All data and configurations\n" + printf "\n" # Try to read from terminal, fallback to stdin if needed printf "Are you sure you want to continue? [y/N]: " @@ -278,7 +278,7 @@ main() { print_header print_info "LazyVim Docker Uninstaller" - echo "" + printf "\n" confirm_uninstall @@ -288,19 +288,19 @@ main() { remove_shell_commands remove_path_modifications - echo "" + printf "\n" print_success "๐Ÿ—‘๏ธ LazyVim Docker has been completely uninstalled!" - echo "" + printf "\n" print_info "What was removed:" print_info " โœ“ Docker containers and images" print_info " โœ“ Installation directory" print_info " โœ“ Global commands" - echo "" + printf "\n" print_info "Thank you for using LazyVim Docker! ๐Ÿš€" - echo "" + printf "\n" print_info "To reinstall later, run:" printf " ${GREEN}curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scripts/start.sh | bash${NC}\n" - echo "" + printf "\n" # Restart terminal to clean up environment restart_terminal diff --git a/scripts/remote-update.sh b/scripts/remote-update.sh index db7ab01..84066b7 100755 --- a/scripts/remote-update.sh +++ b/scripts/remote-update.sh @@ -22,30 +22,30 @@ BACKUP_DIR="$HOME/.local/share/lazyvim-docker-backup-$(date +%Y%m%d-%H%M%S)" # Print functions print_header() { - echo -e "${CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—${NC}" - echo -e "${CYAN}โ•‘ LazyVim Docker - Updater โ•‘${NC}" - echo -e "${CYAN}โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" - echo "" + printf "${CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—${NC}\n" + printf "${CYAN}โ•‘ LazyVim Docker - Updater โ•‘${NC}\n" + printf "${CYAN}โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}\n" + printf "\n" } print_info() { - echo -e "${BLUE}[INFO]${NC} $1" + printf "${BLUE}[INFO]${NC} %s\n" "$1" } print_success() { - echo -e "${GREEN}[SUCCESS]${NC} $1" + printf "${GREEN}[SUCCESS]${NC} %s\n" "$1" } print_warning() { - echo -e "${YELLOW}[WARNING]${NC} $1" + printf "${YELLOW}[WARNING]${NC} %s\n" "$1" } print_error() { - echo -e "${RED}[ERROR]${NC} $1" + printf "${RED}[ERROR]${NC} %s\n" "$1" } print_step() { - echo -e "${PURPLE}[STEP]${NC} $1" + printf "${PURPLE}[STEP]${NC} %s\n" "$1" } # Check if installation exists @@ -53,7 +53,7 @@ check_installation() { if [ ! -d "$INSTALL_DIR" ]; then print_error "LazyVim Docker installation not found at: $INSTALL_DIR" print_info "Please install first:" - echo " curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scripts/start.sh | bash" + printf " curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scripts/start.sh | bash\n" exit 1 fi } @@ -148,8 +148,8 @@ update_installation() { # Rebuild if needed rebuild_containers() { - echo "" - echo -n "Do you want to rebuild Docker containers with the latest changes? [Y/n]: " + printf "\n" + printf "Do you want to rebuild Docker containers with the latest changes? [Y/n]: " read -r response case "$response" in @@ -186,12 +186,12 @@ main() { print_info "Current version: $current_version" print_info "Latest version: $latest_version" - echo "" + printf "\n" if [ "$current_version" = "$latest_version" ] && [ "$current_version" != "unknown" ]; then print_success "You already have the latest version!" - echo "" - echo -n "Do you want to force update anyway? [y/N]: " + printf "\n" + printf "Do you want to force update anyway? [y/N]: " read -r response case "$response" in [yY][eE][sS]|[yY]) @@ -210,15 +210,15 @@ main() { rebuild_containers cleanup - echo "" + printf "\n" print_success "๐ŸŽ‰ LazyVim Docker updated successfully!" - echo "" + printf "\n" print_info "Updated to version: $(get_current_version)" print_info "Backup available at: $BACKUP_DIR" - echo "" + printf "\n" print_info "To start using the updated version:" printf " ${GREEN}lazyvim enter${NC}\n" - echo "" + printf "\n" } # Run main function diff --git a/scripts/setup.sh b/scripts/setup.sh index fc52e26..3908914 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -14,25 +14,25 @@ NC='\033[0m' # Functions log_info() { - echo -e "${BLUE}[INFO]${NC} $1" + printf "${BLUE}[INFO]${NC} %s\n" "$1" } log_success() { - echo -e "${GREEN}[SUCCESS]${NC} $1" + printf "${GREEN}[SUCCESS]${NC} %s\n" "$1" } log_warning() { - echo -e "${YELLOW}[WARNING]${NC} $1" + printf "${YELLOW}[WARNING]${NC} %s\n" "$1" } log_error() { - echo -e "${RED}[ERROR]${NC} $1" + printf "${RED}[ERROR]${NC} %s\n" "$1" } print_header() { - echo -e "${BLUE}=== LazyVim Docker Setup ===${NC}" - echo "This script will help you set up your LazyVim Docker environment" - echo "" + printf "${BLUE}=== LazyVim Docker Setup ===${NC}\n" + printf "This script will help you set up your LazyVim Docker environment\n" + printf "\n" } # Create dotfiles structure @@ -85,8 +85,8 @@ EOF # Configure git settings configure_git() { log_info "Git configuration setup" - echo "Let's configure git for your container environment" - echo "" + printf "Let's configure git for your container environment\n" + printf "\n" read -p "Enter your git username: " GIT_USER read -p "Enter your git email: " GIT_EMAIL @@ -123,8 +123,8 @@ EOF # Configure volumes in docker-compose.yml configure_volumes() { log_info "Volume configuration" - echo "Let's configure the directories you want to mount in your container" - echo "" + printf "Let's configure the directories you want to mount in your container\n" + printf "\n" # Detect OS if [[ "$OSTYPE" == "darwin"* ]]; then @@ -137,15 +137,15 @@ configure_volumes() { DEFAULT_PROJECTS="$HOME/Projects" fi - echo "Detected OS: $OS" - echo "" + printf "Detected OS: %s\n" "$OS" + printf "\n" - echo "Current default mounts:" - echo " - Documents: $DEFAULT_DOCS" - echo "" + printf "Current default mounts:\n" + printf " - Documents: %s\n" "$DEFAULT_DOCS" + printf "\n" read -p "Do you want to add a Projects directory? (y/N): " -n 1 -r - echo + printf "\n" if [[ $REPLY =~ ^[Yy]$ ]]; then read -p "Enter the path to your projects directory [$DEFAULT_PROJECTS]: " PROJECTS_DIR PROJECTS_DIR=${PROJECTS_DIR:-$DEFAULT_PROJECTS} @@ -161,7 +161,7 @@ configure_volumes() { fi read -p "Do you want to add any other custom directories? (y/N): " -n 1 -r - echo + printf "\n" if [[ $REPLY =~ ^[Yy]$ ]]; then while true; do read -p "Enter local directory path (or 'done' to finish): " CUSTOM_DIR @@ -197,42 +197,42 @@ main() { # Create dotfiles structure create_dotfiles_structure - echo "" + printf "\n" # Configure git read -p "Do you want to configure git settings? (y/N): " -n 1 -r - echo + printf "\n" if [[ $REPLY =~ ^[Yy]$ ]]; then configure_git - echo "" + printf "\n" fi # Configure volumes read -p "Do you want to configure volume mounts? (y/N): " -n 1 -r - echo + printf "\n" if [[ $REPLY =~ ^[Yy]$ ]]; then configure_volumes - echo "" + printf "\n" fi # Make scripts executable log_info "Making scripts executable..." chmod +x *.sh scripts/*.sh log_success "Scripts are now executable" - echo "" + printf "\n" # Final message log_success "Setup completed!" - echo "" - echo "Next steps:" - echo " 1. Run 'make build' to build the environment" - echo " 2. Run 'make enter' to start and enter the container" - echo " 3. Configure Neovim and other tools as needed" - echo "" - echo "Useful commands:" - echo " - 'make help' - Show all available commands" - echo " - 'make status' - Check environment status" - echo " - './scripts/health-check.sh' - Run health check" + printf "\n" + printf "Next steps:\n" + printf " 1. Run 'make build' to build the environment\n" + printf " 2. Run 'make enter' to start and enter the container\n" + printf " 3. Configure Neovim and other tools as needed\n" + printf "\n" + printf "Useful commands:\n" + printf " - 'make help' - Show all available commands\n" + printf " - 'make status' - Check environment status\n" + printf " - './scripts/health-check.sh' - Run health check\n" } # Run main function diff --git a/scripts/start.sh b/scripts/start.sh index b5e339a..ecf8d96 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -25,31 +25,31 @@ BRANCH="${LAZYVIM_BRANCH:-main}" # Print functions print_header() { - echo -e "${CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—${NC}" - echo -e "${CYAN}โ•‘ LazyVim Docker - Simple Installer โ•‘${NC}" - echo -e "${CYAN}โ•‘ Smart Defaults, Zero Input โ•‘${NC}" - echo -e "${CYAN}โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" - echo "" + printf "${CYAN}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—${NC}\n" + printf "${CYAN}โ•‘ LazyVim Docker - Simple Installer โ•‘${NC}\n" + printf "${CYAN}โ•‘ Smart Defaults, Zero Input โ•‘${NC}\n" + printf "${CYAN}โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}\n" + printf "\n" } print_info() { - echo -e "${BLUE}[INFO]${NC} $1" + printf "${BLUE}[INFO]${NC} %s\n" "$1" } print_success() { - echo -e "${GREEN}[SUCCESS]${NC} $1" + printf "${GREEN}[SUCCESS]${NC} %s\n" "$1" } print_warning() { - echo -e "${YELLOW}[WARNING]${NC} $1" + printf "${YELLOW}[WARNING]${NC} %s\n" "$1" } print_error() { - echo -e "${RED}[ERROR]${NC} $1" + printf "${RED}[ERROR]${NC} %s\n" "$1" } print_step() { - echo -e "${PURPLE}[STEP]${NC} $1" + printf "${PURPLE}[STEP]${NC} %s\n" "$1" } # Check if command exists @@ -84,19 +84,19 @@ check_requirements() { if [ ${#missing_deps[@]} -ne 0 ]; then print_error "Missing required dependencies: ${missing_deps[*]}" - echo "" + printf "\n" print_info "Please install the missing dependencies and try again:" - echo "" + printf "\n" if [[ "$OSTYPE" == "darwin"* ]]; then - echo " brew install ${missing_deps[*]}" + printf " brew install %s\n" "${missing_deps[*]}" elif [[ "$OSTYPE" == "linux"* ]]; then - echo " # Ubuntu/Debian:" - echo " sudo apt-get update && sudo apt-get install -y ${missing_deps[*]}" - echo "" - echo " # CentOS/RHEL:" - echo " sudo yum install -y ${missing_deps[*]}" + printf " # Ubuntu/Debian:\n" + printf " sudo apt-get update && sudo apt-get install -y %s\n" "${missing_deps[*]}" + printf "\n" + printf " # CentOS/RHEL:\n" + printf " sudo yum install -y %s\n" "${missing_deps[*]}" fi - echo "" + printf "\n" exit 1 fi @@ -153,9 +153,9 @@ setup_local_bin_path() { # Add to PATH if not already there if ! grep -q "$HOME/.local/bin" "$shell_config" 2>/dev/null; then - echo "" >> "$shell_config" - echo "# LazyVim Docker - Add local bin to PATH" >> "$shell_config" - echo "$path_line" >> "$shell_config" + printf "\n" >> "$shell_config" + printf "# LazyVim Docker - Add local bin to PATH\n" >> "$shell_config" + printf "%s\n" "$path_line" >> "$shell_config" print_info "Added $HOME/.local/bin to PATH in $shell_config" fi } @@ -283,7 +283,7 @@ main() { print_info "Installation directory: $INSTALL_DIR" print_info "Binary directory: $BIN_DIR" print_info "Using smart defaults (no interactive input required)" - echo "" + printf "\n" check_requirements create_directories @@ -294,31 +294,31 @@ main() { build_environment cleanup - echo "" + printf "\n" print_success "๐ŸŽ‰ LazyVim Docker installed successfully!" - echo "" + printf "\n" print_info "Configuration applied:" - echo " โ€ข Timezone: Auto-detected from system" - echo " โ€ข Documents: Auto-mounted if exists" - echo " โ€ข Projects: Auto-mounted if exists" - echo "" + printf " โ€ข Timezone: Auto-detected from system\n" + printf " โ€ข Documents: Auto-mounted if exists\n" + printf " โ€ข Projects: Auto-mounted if exists\n" + printf "\n" print_info "Usage:" - echo " ${GREEN}lazy enter${NC} # Enter LazyVim development environment" - echo " ${GREEN}lazy start${NC} # Start the container" - echo " ${GREEN}lazy stop${NC} # Stop the container" - echo " ${GREEN}lazy status${NC} # Check container status" - echo " ${GREEN}lazy configure${NC} # Reconfigure directories and timezone" - echo " ${GREEN}lazy update${NC} # Update to latest version" - echo " ${GREEN}lazy uninstall${NC} # Uninstall everything" - echo " ${GREEN}lazy help${NC} # Show all available commands" - echo "" + printf " ${GREEN}lazy enter${NC} # Enter LazyVim development environment\n" + printf " ${GREEN}lazy start${NC} # Start the container\n" + printf " ${GREEN}lazy stop${NC} # Stop the container\n" + printf " ${GREEN}lazy status${NC} # Check container status\n" + printf " ${GREEN}lazy configure${NC} # Reconfigure directories and timezone\n" + printf " ${GREEN}lazy update${NC} # Update to latest version\n" + printf " ${GREEN}lazy uninstall${NC} # Uninstall everything\n" + printf " ${GREEN}lazy help${NC} # Show all available commands\n" + printf "\n" print_info "To get started:" - echo " 1. Restart your terminal or run: ${YELLOW}source ~/.zshrc${NC} (or ~/.bashrc)" - echo " 2. Run: ${GREEN}lazy enter${NC}" - echo "" + printf " 1. Restart your terminal or run: ${YELLOW}source ~/.zshrc${NC} (or ~/.bashrc)\n" + printf " 2. Run: ${GREEN}lazy enter${NC}\n" + printf "\n" print_info "To customize configuration later:" - echo " Run: ${GREEN}lazy configure${NC}" - echo "" + printf " Run: ${GREEN}lazy configure${NC}\n" + printf "\n" print_info "Happy coding! ๐Ÿš€" } diff --git a/scripts/uninstall-global-commands.sh b/scripts/uninstall-global-commands.sh index 5f9dd06..73ef6f1 100755 --- a/scripts/uninstall-global-commands.sh +++ b/scripts/uninstall-global-commands.sh @@ -106,9 +106,9 @@ remove_project_directory() { # Get parent directory (remove /scripts) project_dir="$(dirname "$project_dir")" - echo + printf "\n" print_status "Current project directory: $project_dir" - echo + printf "\n" printf "Do you want to remove the entire LazyVim Docker project directory? [y/N]: " if [[ -t 0 ]] && [[ -t 1 ]] && [[ $- == *i* ]]; then read -r response Date: Tue, 8 Jul 2025 16:36:47 -0600 Subject: [PATCH 3/4] refactor: update default target to 'make' and remove 'help' command references for consistency --- Makefile | 22 +++++++++------------- README.md | 17 ++++++++--------- docs/COMMANDS.md | 4 +--- scripts/install-global-commands.sh | 18 ++++++------------ scripts/setup.sh | 2 +- scripts/start.sh | 1 - 6 files changed, 25 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 8fbcdab..f055544 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,18 @@ # LazyVim Docker - Makefile # Provides easy-to-use commands for managing the LazyVim Docker environment -.PHONY: help build start enter stop destroy clean status update logs backup restore dev quick version bump-version restart +.PHONY: default build start enter stop destroy clean status update backup restore dev quick version bump-version restart .PHONY: install-global uninstall install-remote remote-uninstall remote-update configure # Default target -.DEFAULT_GOAL := help +.DEFAULT_GOAL := default + +default: # Show all available commands (default when running 'make') + @echo "$(BLUE)LazyVim Docker Environment - Available Commands$(NC)" + @echo "" + @awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*##/ { printf "$(GREEN)%-15s$(NC) %s\n", $$1, $$2 }' $(MAKEFILE_LIST) + @echo "" + @echo "$(YELLOW)Current version: $(VERSION)$(NC)" # Colors for output RED := \033[0;31m @@ -26,13 +33,6 @@ USER_GID := $(shell if [ "$(shell uname)" = "Linux" ]; then id -g; else echo "10 # Docker compose with environment variables for Linux permission compatibility DOCKER_COMPOSE := USER_UID=$(USER_UID) USER_GID=$(USER_GID) docker compose -help: ## Show this help message - @echo "$(BLUE)LazyVim Docker Environment - Available Commands$(NC)" - @echo "" - @awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*##/ { printf "$(GREEN)%-15s$(NC) %s\n", $$1, $$2 }' $(MAKEFILE_LIST) - @echo "" - @echo "$(YELLOW)Current version: $(VERSION)$(NC)" - build: ## Build the Docker environment (clean build) @echo "$(BLUE)Building LazyVim Docker environment v$(VERSION)...$(NC)" @./scripts/build.sh @@ -117,10 +117,6 @@ status: ## Show container status docker compose ps; \ fi -logs: ## Show container logs - @echo "$(BLUE)Container Logs:$(NC)" - @docker compose logs -f --tail=50 - update: ## Update to latest version and rebuild @echo "$(BLUE)Updating LazyVim environment...$(NC)" @git pull origin main || echo "$(YELLOW)Could not pull latest changes$(NC)" diff --git a/README.md b/README.md index 06f3a32..6738821 100644 --- a/README.md +++ b/README.md @@ -73,19 +73,18 @@ lazy status # Check container status lazy build # Build/rebuild environment lazy update # Update to latest version lazy uninstall # Complete removal -lazy help # Show all available commands ``` ### ๐Ÿ“ Local Commands (Traditional Installation) From the project directory: ```bash -make help # Show all available commands -make enter # ๐Ÿ”ฅ DAILY USE: Enter container (starts automatically if stopped) -make start # Start existing container (preserves all data) -make stop # Stop container (saves all data and plugins) -make status # Check container status -make build # โš ๏ธ ONLY for first time or major updates -make destroy # โš ๏ธ DANGEROUS: Removes everything +make # Show all available commands (default target) +make enter # ๐Ÿ”ฅ DAILY USE: Enter container (starts automatically if stopped) +make start # Start existing container (preserves all data) +make stop # Stop container (saves all data and plugins) +make status # Check container status +make build # โš ๏ธ ONLY for first time or major updates +make destroy # โš ๏ธ DANGEROUS: Removes everything ``` > ๐Ÿ’ก **For daily development**: Use `lazy enter` (remote) or `make enter` (traditional) @@ -371,7 +370,7 @@ volumes: ### Health Check Commands ```bash lazy status # Container status -lazy help # Available commands +lazy # Available commands make health # Comprehensive diagnostics (traditional) ``` diff --git a/docs/COMMANDS.md b/docs/COMMANDS.md index a7095b1..c35cba2 100644 --- a/docs/COMMANDS.md +++ b/docs/COMMANDS.md @@ -10,7 +10,7 @@ This document provides a comprehensive guide to all available commands in the La | Command | Description | Example | |---------|-------------|---------| -| `make help` | Show all available commands with descriptions | `make help` | +| `make` | Show all available commands with descriptions (default target) | `make` | | `make version` | Show current project version | `make version` | | `make status` | Show container and environment status | `make status` | | `make health` | Run comprehensive health diagnostics | `make health` | @@ -31,7 +31,6 @@ This document provides a comprehensive guide to all available commands in the La | Command | Description | Example | |---------|-------------|---------| | `make dev` | Start in development mode with workspace mounted | `make dev` | -| `make logs` | Show container logs (follow mode) | `make logs` | | `make update` | Update to latest version and rebuild | `make update` | ### Maintenance @@ -156,7 +155,6 @@ make update # Update to latest ### Troubleshooting ```bash ./scripts/health-check.sh # Diagnose issues -make logs # Check container logs make destroy && make build # Nuclear option - rebuild everything ``` diff --git a/scripts/install-global-commands.sh b/scripts/install-global-commands.sh index ed21191..8808efb 100755 --- a/scripts/install-global-commands.sh +++ b/scripts/install-global-commands.sh @@ -43,7 +43,6 @@ printf " lazy stop -> make stop\n" printf " lazy status -> make status\n" printf " lazy build -> make build\n" printf " lazy health -> make health\n" -printf " lazy help -> make help\n" printf " lazy uninstall -> Complete removal (same as curl method)\n" printf "\n" @@ -81,12 +80,11 @@ lazyvim_docker_path="$LAZYVIM_DOCKER_PATH" lazy() { if [[ \$# -eq 0 ]]; then - printf "LazyVim Docker - Global Commands\n" + printf "LazyVim Docker - Available Commands\n" printf "\n" printf "Usage: lazy \n" printf "\n" printf "Available commands:\n" - printf " help Show all available commands\n" printf " start Start the container\n" printf " enter Enter the container (starts if stopped)\n" printf " stop Stop the container\n" @@ -97,7 +95,6 @@ lazy() { printf " destroy Destroy everything\n" printf " clean Clean up Docker resources\n" printf " quick Quick start (build + enter)\n" - printf " logs Show container logs\n" printf " backup Backup configurations\n" printf " version Show version\n" printf " configure Reconfigure directories and timezone\n" @@ -113,7 +110,7 @@ lazy() { shift case "\$cmd" in - help|start|enter|stop|status|health|build|restart|destroy|clean|quick|logs|backup|configure|version) + start|enter|stop|status|health|build|restart|destroy|clean|quick|backup|configure|version) printf "๐Ÿš€ Running: make %s %s\n" "\$cmd" "\$@" (cd "\$lazyvim_docker_path" && make "\$cmd" "\$@") ;; @@ -131,7 +128,7 @@ lazy() { # Tab completion for lazy command (Zsh) _lazy_zsh_completion() { - local commands=(help start enter stop status health build restart destroy clean quick logs backup configure version uninstall) + local commands=(start enter stop status health build restart destroy clean quick backup configure version uninstall) _describe 'lazy commands' commands } @@ -170,12 +167,11 @@ lazyvim_docker_path="$LAZYVIM_DOCKER_PATH" lazy() { if [[ \$# -eq 0 ]]; then - printf "LazyVim Docker - Global Commands\n" + printf "LazyVim Docker - Available Commands\n" printf "\n" printf "Usage: lazy \n" printf "\n" printf "Available commands:\n" - printf " help Show all available commands\n" printf " start Start the container\n" printf " enter Enter the container (starts if stopped)\n" printf " stop Stop the container\n" @@ -186,7 +182,6 @@ lazy() { printf " destroy Destroy everything\n" printf " clean Clean up Docker resources\n" printf " quick Quick start (build + enter)\n" - printf " logs Show container logs\n" printf " backup Backup configurations\n" printf " version Show version\n" printf " configure Reconfigure directories and timezone\n" @@ -202,7 +197,7 @@ lazy() { shift case "\$cmd" in - help|start|enter|stop|status|health|build|restart|destroy|clean|quick|logs|backup|configure|version) + start|enter|stop|status|health|build|restart|destroy|clean|quick|backup|configure|version) printf "๐Ÿš€ Running: make %s %s\n" "\$cmd" "\$@" (cd "\$lazyvim_docker_path" && make "\$cmd" "\$@") ;; @@ -221,7 +216,7 @@ lazy() { # Tab completion for lazy command (Bash) _lazy_completion() { local cur="\${COMP_WORDS[COMP_CWORD]}" - local commands="help start enter stop status health build restart destroy clean quick logs backup configure version uninstall" + local commands="start enter stop status health build restart destroy clean quick backup configure version uninstall" COMPREPLY=(\$(compgen -W "\$commands" -- "\$cur")) } @@ -252,7 +247,6 @@ install_global_commands() { printf "\n" log_info "Usage:" printf " lazy enter # Enter LazyVim development environment\n" - printf " lazy help # Show all available commands\n" printf "\n" log_info "To activate:" printf " โ€ข Restart your terminal, or\n" diff --git a/scripts/setup.sh b/scripts/setup.sh index 3908914..fd534be 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -230,7 +230,7 @@ main() { printf " 3. Configure Neovim and other tools as needed\n" printf "\n" printf "Useful commands:\n" - printf " - 'make help' - Show all available commands\n" + printf " - 'make' - Show all available commands\n" printf " - 'make status' - Check environment status\n" printf " - './scripts/health-check.sh' - Run health check\n" } diff --git a/scripts/start.sh b/scripts/start.sh index ecf8d96..408e51e 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -310,7 +310,6 @@ main() { printf " ${GREEN}lazy configure${NC} # Reconfigure directories and timezone\n" printf " ${GREEN}lazy update${NC} # Update to latest version\n" printf " ${GREEN}lazy uninstall${NC} # Uninstall everything\n" - printf " ${GREEN}lazy help${NC} # Show all available commands\n" printf "\n" print_info "To get started:" printf " 1. Restart your terminal or run: ${YELLOW}source ~/.zshrc${NC} (or ~/.bashrc)\n" From 673cc84e6b3bb7a0b2a12679ee0c13e76d63817d Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Tue, 8 Jul 2025 16:41:07 -0600 Subject: [PATCH 4/4] chore: bump version to 1.3.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1892b92..31e5c84 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.2 +1.3.3