From 7baf40936cdc5e52df241253aa2bfe1d2d00569d Mon Sep 17 00:00:00 2001 From: Marco Gallegos Date: Sat, 8 Nov 2025 16:07:44 -0600 Subject: [PATCH] Ajuste de .bashrc, para que cargu zsh por default --- modules/apps.sh | 21 ++++++++++++++++ modules/zsh-config.sh | 56 +++++++++++++++++++++++++++++++++---------- 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/modules/apps.sh b/modules/apps.sh index ce583cb..5f9f47e 100755 --- a/modules/apps.sh +++ b/modules/apps.sh @@ -6,6 +6,24 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${SCRIPT_DIR}/common.sh" +install_homebrew() { + log_step "Instalación de Homebrew (Linuxbrew)" + + if command_exists brew; then + log_success "Homebrew ya está instalado." + return 0 + fi + + log_info "Instalando Homebrew..." + # Instalar de forma no interactiva + if NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then + log_success "Homebrew instalado correctamente." + else + log_error "Falló la instalación de Homebrew." + return 1 + fi +} + install_apps() { log_step "Instalación de Aplicaciones" @@ -19,6 +37,9 @@ install_apps() { log_error "Error al instalar herramientas base" return 1 } + + # Instalar Homebrew + install_homebrew # Aplicaciones multimedia log_info "Instalando aplicaciones multimedia..." diff --git a/modules/zsh-config.sh b/modules/zsh-config.sh index a086fe0..03963da 100755 --- a/modules/zsh-config.sh +++ b/modules/zsh-config.sh @@ -9,6 +9,39 @@ source "${SCRIPT_DIR}/common.sh" # Usar REPO_BASE si está definido, sino usar el valor por defecto REPO_BASE="${REPO_BASE:-https://raw.githubusercontent.com/marcogll/omarchy_setup/main}" +configure_bashrc_to_launch_zsh() { + local bashrc_file="$HOME/.bashrc" + local block_marker="# OMARCHY: AUTO-LAUNCH ZSH" + + if [[ -f "$bashrc_file" ]] && grep -qF "$block_marker" "$bashrc_file"; then + log_success ".bashrc ya está configurado para lanzar Zsh." + return 0 + fi + + log_info "Configurando .bashrc para lanzar Zsh automáticamente..." + + # Crear copia de seguridad + if [[ -f "$bashrc_file" ]]; then + cp "$bashrc_file" "${bashrc_file}.bak_$(date +%F_%T)" + log_info "Copia de seguridad de .bashrc creada en ${bashrc_file}.bak_..." + fi + + # Añadir el bloque de código a .bashrc + cat >> "$bashrc_file" << 'EOF' + +# OMARCHY: AUTO-LAUNCH ZSH +# Lanzar Zsh automáticamente si no estamos ya en Zsh +if [ -t 1 ] && [ -z "$ZSH_VERSION" ] && command -v zsh &>/dev/null; then + # Inicializar Homebrew si existe antes de cambiar de shell + if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + fi + exec zsh +fi +EOF + log_success ".bashrc modificado para iniciar Zsh." +} + install_zsh() { log_step "Configuración de Zsh" @@ -23,6 +56,13 @@ install_zsh() { # Descargar configuración personalizada log_info "Descargando configuración de Zsh desde GitHub..." if curl -fsSL "${REPO_BASE}/.zshrc" -o ~/.zshrc; then + # Añadir configuración de Homebrew si está instalado + if [[ -x "/home/linuxbrew/.linuxbrew/bin/brew" ]]; then + log_info "Añadiendo configuración de Homebrew a .zshrc..." + echo '' >> ~/.zshrc + echo '# Homebrew' >> ~/.zshrc + echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.zshrc + fi log_success "Configuración de Zsh descargada" else log_warning "No se pudo descargar .zshrc desde GitHub" @@ -52,19 +92,9 @@ alias ...='cd ../..' EOF fi - # Configurar Zsh como shell predeterminada - if [ "$SHELL" != "/bin/zsh" ] && [ "$SHELL" != "/usr/bin/zsh" ]; then - log_info "Configurando Zsh como shell predeterminada..." - if chsh -s /bin/zsh 2>/dev/null || chsh -s /usr/bin/zsh 2>/dev/null; then - log_success "Zsh configurado como shell predeterminada" - log_warning "Los cambios surtirán efecto en la próxima sesión" - else - log_warning "No se pudo cambiar la shell. Ejecuta manualmente: chsh -s /bin/zsh" - fi - else - log_success "Zsh ya es la shell predeterminada" - fi - + # Modificar .bashrc para que lance zsh + configure_bashrc_to_launch_zsh + log_success "Configuración de Zsh completada" return 0 }