mirror of
https://github.com/marcogll/mac_vntySet.git
synced 2026-01-13 13:25:15 +00:00
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.
This commit is contained in:
@@ -138,7 +138,12 @@ install_homebrew() {
|
||||
brew_ensure_formula() {
|
||||
local formula="$1"
|
||||
if brew list --formula "$formula" >/dev/null 2>&1; then
|
||||
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."
|
||||
|
||||
Reference in New Issue
Block a user