From 1dd1e3f78fa7f8dd7fcd84062f99d1f3f75c6d98 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 18:31:24 +0000 Subject: [PATCH 1/3] fix(vanity_setup): Evita errores al instalar fuentes existentes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se modifica la función 'brew_ensure_cask' para detectar y omitir la instalación de casks de fuentes que ya existen en el sistema. Esto evita que el script se detenga con un error cuando una fuente ya está presente, lo que hace que el proceso de instalación sea más robusto. --- vanity_setup.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vanity_setup.sh b/vanity_setup.sh index 118e061..3c8589e 100644 --- a/vanity_setup.sh +++ b/vanity_setup.sh @@ -154,7 +154,16 @@ brew_ensure_cask() { fi echo "➜ Instalando ${cask}…" - brew install --cask "$cask" + local output + if ! output=$(brew install --cask "$cask" 2>&1); then + if [[ "$output" == *"already a Font at"* ]]; then + echo "✔︎ La fuente de ${cask} ya existe. Omitiendo." + else + echo "$output" >&2 + echo "Error al instalar ${cask}." >&2 + return 1 + fi + fi } install_cli_dependencies() { From 972743df41f6c61b3ec2b683c1ef769c7df85f72 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 18:39:09 +0000 Subject: [PATCH 2/3] fix(vanity_setup): Improve script robustness and fix runtime errors This commit addresses three separate issues identified during the execution of the vanity setup script: 1. **Handle existing fonts gracefully**: The `brew_ensure_cask` function is modified to catch the specific error that occurs when a font cask is installed but the font file already exists. Instead of failing, the script now reports the font as already present and continues. 2. **Fix Docker plugin load order**: The `install_zsh_config` function now prepends the `brew shellenv` command to the downloaded `.zshrc` file. This ensures the Homebrew PATH is set *before* Oh My Zsh loads its plugins, resolving the `command not found: docker` error on shell startup. 3. **Automatically update yt-dlp**: The `brew_ensure_formula` function is updated to automatically run `brew upgrade yt-dlp` if the formula is already installed. This keeps the tool up-to-date and prevents download failures (like HTTP 403 errors) caused by an outdated version. --- vanity_setup.sh | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/vanity_setup.sh b/vanity_setup.sh index 118e061..c888e33 100644 --- a/vanity_setup.sh +++ b/vanity_setup.sh @@ -138,7 +138,12 @@ install_homebrew() { brew_ensure_formula() { local formula="$1" if brew list --formula "$formula" >/dev/null 2>&1; then - echo "✔︎ ${formula} ya está instalado. Omitiendo." + if [[ "$formula" == "yt-dlp" ]]; then + echo "➜ yt-dlp ya está instalado. Actualizando a la última versión…" + brew upgrade yt-dlp + else + echo "✔︎ ${formula} ya está instalado. Omitiendo." + fi return fi @@ -154,7 +159,16 @@ brew_ensure_cask() { fi echo "➜ Instalando ${cask}…" - brew install --cask "$cask" + local output + if ! output=$(brew install --cask "$cask" 2>&1); then + if [[ "$output" == *"already a Font at"* ]]; then + echo "✔︎ La fuente de ${cask} ya existe. Omitiendo." + else + echo "$output" >&2 + echo "Error al instalar ${cask}." >&2 + return 1 + fi + fi } install_cli_dependencies() { @@ -257,12 +271,23 @@ install_zsh_config() { mkdir -p "$HOME/.poshthemes" curl -fsSL "$POSH_THEME_URL" -o "$POSH_THEME_PATH" - echo "Descargando .zshrc de Vanity Shell…" - if ! curl -fsSL "$ZSHRC_URL" -o "$HOME/.zshrc"; then + echo "Descargando y configurando .zshrc de Vanity Shell…" + local zshrc_content + if ! zshrc_content=$(curl -fsSL "$ZSHRC_URL"); then echo "No se pudo descargar la configuración de ZSH." >&2 exit 1 fi + local brew_init_line="" + if [ -n "$BREW_BIN" ]; then + # Esta línea se añade al principio para garantizar que el PATH de Homebrew + # se configure ANTES de que Oh My Zsh intente cargar plugins como 'docker'. + brew_init_line="eval \"\$($BREW_BIN shellenv)\"" + fi + + # Combina la inicialización de Homebrew con el contenido descargado + echo -e "${brew_init_line}\n\n${zshrc_content}" > "$HOME/.zshrc" + if command -v pbcopy >/dev/null 2>&1; then echo "source ~/.zshrc" | pbcopy echo "El comando 'source ~/.zshrc' fue copiado al portapapeles." From a7c48a5d023023aaf6375bd757b79547f343ee1b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 19:05:36 +0000 Subject: [PATCH 3/3] feat(vanity_setup): Add menu option to update packages Introduces a new 'P' option in the main menu to update all installed Homebrew packages. This is achieved by a new 'update_packages' function that runs 'brew upgrade'. This provides a convenient way for users to keep their development environment up-to-date directly from the script. --- vanity_setup.sh | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/vanity_setup.sh b/vanity_setup.sh index 118e061..cb81eb5 100644 --- a/vanity_setup.sh +++ b/vanity_setup.sh @@ -138,7 +138,12 @@ install_homebrew() { brew_ensure_formula() { local formula="$1" if brew list --formula "$formula" >/dev/null 2>&1; then - echo "✔︎ ${formula} ya está instalado. Omitiendo." + if [[ "$formula" == "yt-dlp" ]]; then + echo "➜ yt-dlp ya está instalado. Actualizando a la última versión…" + brew upgrade yt-dlp + else + echo "✔︎ ${formula} ya está instalado. Omitiendo." + fi return fi @@ -154,7 +159,16 @@ brew_ensure_cask() { fi echo "➜ Instalando ${cask}…" - brew install --cask "$cask" + local output + if ! output=$(brew install --cask "$cask" 2>&1); then + if [[ "$output" == *"already a Font at"* ]]; then + echo "✔︎ La fuente de ${cask} ya existe. Omitiendo." + else + echo "$output" >&2 + echo "Error al instalar ${cask}." >&2 + return 1 + fi + fi } install_cli_dependencies() { @@ -257,12 +271,23 @@ install_zsh_config() { mkdir -p "$HOME/.poshthemes" curl -fsSL "$POSH_THEME_URL" -o "$POSH_THEME_PATH" - echo "Descargando .zshrc de Vanity Shell…" - if ! curl -fsSL "$ZSHRC_URL" -o "$HOME/.zshrc"; then + echo "Descargando y configurando .zshrc de Vanity Shell…" + local zshrc_content + if ! zshrc_content=$(curl -fsSL "$ZSHRC_URL"); then echo "No se pudo descargar la configuración de ZSH." >&2 exit 1 fi + local brew_init_line="" + if [ -n "$BREW_BIN" ]; then + # Esta línea se añade al principio para garantizar que el PATH de Homebrew + # se configure ANTES de que Oh My Zsh intente cargar plugins como 'docker'. + brew_init_line="eval \"\$($BREW_BIN shellenv)\"" + fi + + # Combina la inicialización de Homebrew con el contenido descargado + echo -e "${brew_init_line}\n\n${zshrc_content}" > "$HOME/.zshrc" + if command -v pbcopy >/dev/null 2>&1; then echo "source ~/.zshrc" | pbcopy echo "El comando 'source ~/.zshrc' fue copiado al portapapeles." @@ -333,6 +358,14 @@ install_docker_stack() { portainer/portainer-ce:latest >/dev/null } +update_packages() { + echo "Actualizando la lista de paquetes de Homebrew…" + install_homebrew + echo "Actualizando todos los paquetes de Homebrew instalados…" + brew upgrade + echo "Todos los paquetes han sido actualizados." +} + ensure_xcode_clt() { if xcode-select -p >/dev/null 2>&1; then return @@ -415,11 +448,12 @@ main_menu() { echo " A) Instalar TODO (recomendado)" echo " C) Instalar solo configuración ZSH" echo " D) Instalar Docker + Portainer + Lazydocker" + echo " P) Actualizar paquetes Homebrew" echo " U) Actualizar componentes instalados" echo " Q) Salir" echo "" local choice="" - if read_menu_choice "Opción [A/C/D/U/Q]: "; then + if read_menu_choice "Opción [A/C/D/P/U/Q]: "; then choice="$REPLY" else echo "No se detecta una entrada interactiva; se seleccionará la opción 'A' por defecto." @@ -440,6 +474,9 @@ main_menu() { install_homebrew install_docker_stack ;; + P|p) + update_packages + ;; U|u) echo "Actualizando la instalación existente…" install_homebrew