feat: Add an update option to the script and ensure Homebrew packages are installed only if missing.

This commit is contained in:
Marco Gallegos
2025-11-21 08:21:48 -06:00
parent 1502e4c2dc
commit e18adc35bc
2 changed files with 53 additions and 3 deletions

View File

@@ -65,14 +65,55 @@ install_homebrew() {
brew update
}
brew_ensure_formula() {
local formula="$1"
if brew list --formula "$formula" >/dev/null 2>&1; then
echo "✔︎ ${formula} ya está instalado. Omitiendo."
return
fi
echo "➜ Instalando ${formula}"
brew install "$formula"
}
brew_ensure_cask() {
local cask="$1"
if brew list --cask "$cask" >/dev/null 2>&1; then
echo "✔︎ ${cask} ya está instalado. Omitiendo."
return
fi
echo "➜ Instalando ${cask}"
brew install --cask "$cask"
}
install_cli_dependencies() {
echo "Instalando herramientas base de desarrollo…"
brew install zsh curl wget git jq yq node python go direnv yt-dlp ffmpeg zerotier-one speedtest-cli
local formulas=(
zsh
curl
wget
git
jq
yq
node
python
go
direnv
yt-dlp
ffmpeg
speedtest-cli
jandedobbeleer/oh-my-posh/oh-my-posh
)
for formula in "${formulas[@]}"; do
brew_ensure_formula "$formula"
done
echo "Instalando Oh My Posh y fuentes Nerd Font…"
brew tap homebrew/cask-fonts >/dev/null 2>&1 || true
brew install --cask --force font-meslo-lg-nerd-font
brew install jandedobbeleer/oh-my-posh/oh-my-posh
brew_ensure_cask font-meslo-lg-nerd-font
brew_ensure_cask zerotier-one
}
setup_media_dirs() {
@@ -294,6 +335,7 @@ main_menu() {
echo " A) Instalar TODO (recomendado)"
echo " C) Instalar solo configuración ZSH"
echo " D) Instalar Docker + Portainer + Lazydocker"
echo " U) Actualizar componentes instalados"
echo " Q) Salir"
echo ""
local choice=""
@@ -318,6 +360,12 @@ main_menu() {
install_homebrew
install_docker_stack
;;
U|u)
echo "Actualizando la instalación existente…"
install_homebrew
install_zsh_config
install_docker_stack
;;
Q|q)
echo "Saliendo…"
exit 0