feat: add dev tools, AI aliases, and improve zshrc documentation

This commit introduces several new features and improvements:

- **Adds Development Tools to `apps.sh`:** The `apps.sh` module now installs essential development tools, including `python`, `pip`, `nodejs`, `npm`, `uv`, and `nvm`.

- **Implements `.zshrc.local` for Private Variables:**
  - A `.zshrc.local.example` file has been added to serve as a template for users to securely store their private environment variables, such as API keys.
  - The main `.zshrc` file now sources `.zshrc.local` if it exists.

- **Adds AI Aliases to `.zshrc`:** A new section has been added to `.zshrc` with example aliases for interacting with command-line AI tools.

- **Improves `.zshrc` Documentation:** The `.zshrc` file has been thoroughly documented with comments in Spanish, explaining the purpose of each section. The title has also been updated and professionalized.

- **Fixes a Regression:** This commit restores the `ytm`, `ytv`, `ytls`, and SSH agent functions in `.zshrc` that were accidentally removed in a previous step.
This commit is contained in:
google-labs-jules[bot]
2025-11-19 05:54:11 +00:00
parent 9ec39b548f
commit d867afec5e
7 changed files with 389 additions and 139 deletions

View File

@@ -2,63 +2,190 @@
# ===============================================================
# apps.sh - Instalación de aplicaciones esenciales
# ===============================================================
#
# Este módulo se encarga de instalar y configurar una amplia gama
# de aplicaciones y herramientas de sistema.
#
# Funciones principales:
# - Instala Homebrew (Linuxbrew) para gestionar paquetes adicionales.
# - Instala paquetes desde los repositorios de Arch (pacman) y desde AUR.
# - Organiza los paquetes por categorías (base, multimedia, red, etc.).
# - Configura drivers para gráficos Intel Iris Xe.
# - Configura GNOME Keyring para la gestión de contraseñas y claves SSH.
# - Habilita servicios del sistema para aplicaciones como keyd, logiops y TeamViewer.
#
# ===============================================================
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/common.sh"
# ---------------------------------------------------------------
# ensure_homebrew_env()
# ---------------------------------------------------------------
# Asegura que el entorno de Homebrew esté configurado correctamente.
#
# Esta función realiza dos tareas principales:
# 1. Carga Homebrew en la sesión de shell actual para que el comando `brew`
# esté disponible inmediatamente después de la instalación.
# 2. Añade la línea de inicialización de Homebrew a los ficheros de
# perfil del usuario (`.profile` y `.zprofile`) para que `brew`
# esté disponible en futuras sesiones de terminal.
#
# Parámetros:
# $1 - Ruta al ejecutable de brew.
# ---------------------------------------------------------------
ensure_homebrew_env() {
local brew_bin="$1"
if [[ ! -x "$brew_bin" ]]; then
return 1
fi
# Evalúa `shellenv` para que el resto del módulo pueda usar `brew`
# sin necesidad de reiniciar la shell.
eval "$("$brew_bin" shellenv)" || return 1
local shell_snippet='eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'
local -a appended=()
local -a rc_targets=("${HOME}/.profile")
# Si el usuario utiliza Zsh, añade también la configuración a .zprofile.
if [[ -n "${SHELL:-}" && "$(basename "${SHELL}")" == "zsh" ]]; then
rc_targets+=("${HOME}/.zprofile")
fi
for rc_file in "${rc_targets[@]}"; do
if [[ -f "$rc_file" ]] && grep -Fq "$shell_snippet" "$rc_file"; then
continue
fi
{
echo ""
echo "# Configuración añadida por Omarchy Setup para inicializar Homebrew"
echo "$shell_snippet"
} >> "$rc_file"
appended+=("$rc_file")
done
if [[ ${#appended[@]} -gt 0 ]]; then
log_info "Se añadió la inicialización de Homebrew a: ${appended[*]}."
fi
return 0
}
# ---------------------------------------------------------------
# install_homebrew()
# ---------------------------------------------------------------
# Instala Homebrew (conocido como Linuxbrew en Linux).
#
# Comprueba si Homebrew ya está instalado. Si no lo está, descarga y
# ejecuta el script de instalación oficial de forma no interactiva.
# Después de la instalación, llama a `ensure_homebrew_env` para
# configurar el entorno de shell.
# ---------------------------------------------------------------
install_homebrew() {
log_step "Instalación de Homebrew (Linuxbrew)"
local brew_path="/home/linuxbrew/.linuxbrew/bin/brew"
if command_exists brew; then
brew_path="$(command -v brew)"
fi
if command_exists brew || [[ -x "$brew_path" ]]; then
log_success "Homebrew ya está instalado."
ensure_homebrew_env "${brew_path}" || true
return 0
fi
log_info "Instalando Homebrew..."
# Instalar de forma no interactiva
# Instala de forma no interactiva para evitar prompts.
if NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
log_success "Homebrew instalado correctamente."
ensure_homebrew_env "${brew_path}" || log_warning "Homebrew se instaló pero no se pudo configurar la shell automáticamente."
else
log_error "Falló la instalación de Homebrew."
return 1
fi
}
# ---------------------------------------------------------------
# install_nvm()
# ---------------------------------------------------------------
# Instala NVM (Node Version Manager).
#
# Descarga y ejecuta el script de instalación oficial de NVM.
# ---------------------------------------------------------------
install_nvm() {
log_step "Instalación de NVM (Node Version Manager)"
if [[ -d "${HOME}/.nvm" ]]; then
log_success "NVM ya está instalado."
return 0
fi
log_info "Instalando NVM..."
if curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash; then
log_success "NVM instalado correctamente."
log_info "Para usar NVM, reinicia tu terminal o ejecuta: source ~/.nvm/nvm.sh"
else
log_error "Falló la instalación de NVM."
return 1
fi
}
# ---------------------------------------------------------------
# run_module_main()
# ---------------------------------------------------------------
# Función principal del módulo de instalación de aplicaciones.
#
# Ejecuta una secuencia de tareas para instalar y configurar
# aplicaciones esenciales del sistema.
# ---------------------------------------------------------------
run_module_main() {
log_step "Instalación de Aplicaciones"
# --- Definición de Paquetes ---
# Paquetes base para el sistema y desarrollo.
local PACMAN_BASE=(
git curl wget base-devel unzip htop fastfetch btop
vim nano tmux xdg-utils xdg-user-dirs stow
gnome-keyring libsecret seahorse openssh rsync
)
# Paquetes para desarrollo de software.
local PACMAN_DEV=(
python python-pip nodejs npm uv
)
# Paquetes para reproducción y edición multimedia.
local PACMAN_MULTIMEDIA=(
vlc vlc-plugins-all libdvdcss audacity inkscape
ffmpeg gstreamer gst-plugins-good gst-plugins-bad gst-plugins-ugly
yt-dlp
)
# Aplicaciones de red y conectividad.
local PACMAN_NETWORK=(
filezilla telegram-desktop scrcpy speedtest-cli
)
# Drivers para gráficos Intel (Mesa y Vulkan).
local PACMAN_INTEL_GFX=(
mesa vulkan-intel lib32-mesa lib32-vulkan-intel
)
# Drivers para aceleración de vídeo por hardware en Intel (VA-API).
local PACMAN_INTEL_VIDEO=(
intel-media-driver libva-utils libvdpau-va-gl libva-mesa-driver
)
# Soporte para computación GPGPU con OpenCL.
local PACMAN_OPENCL=(
ocl-icd libclc clinfo
)
# Paquetes a instalar desde el Arch User Repository (AUR).
local AUR_PACKAGES=(
"visual-studio-code-bin" "cursor-bin" "keyd" "fragments"
"logiops" "ltunify" "teamviewer" "intel-compute-runtime"
)
# --- Instalación de Paquetes ---
log_info "Actualizando el sistema para evitar conflictos de dependencias..."
sudo pacman -Syu --noconfirm || {
log_warning "No se pudo completar la actualización del sistema. Pueden ocurrir errores de dependencias."
# Continuamos de todos modos, pero con una advertencia.
}
log_info "Instalando herramientas base..."
@@ -67,6 +194,14 @@ run_module_main() {
return 1
}
log_info "Instalando herramientas de desarrollo..."
sudo pacman -S --noconfirm --needed "${PACMAN_DEV[@]}" || {
log_warning "Algunas herramientas de desarrollo no se pudieron instalar"
}
# Instalar NVM
install_nvm
# Instalar Homebrew
install_homebrew
@@ -75,6 +210,7 @@ run_module_main() {
log_warning "Algunos paquetes multimedia no se pudieron instalar"
}
# Configura VLC como el reproductor por defecto para los tipos de archivo más comunes.
log_info "Configurando VLC como reproductor predeterminado..."
local mime_types=("audio/mpeg" "audio/mp4" "audio/x-wav" "video/mp4" "video/x-matroska" "video/x-msvideo" "video/x-ms-wmv" "video/webm")
for type in "${mime_types[@]}"; do
@@ -86,14 +222,15 @@ run_module_main() {
log_warning "Algunos paquetes de red no se pudieron instalar"
}
# Flatpak
log_info "Instalando Flatpak..."
sudo pacman -S --noconfirm --needed flatpak || {
log_warning "Flatpak no se pudo instalar"
}
# --- Configuración de Drivers Intel ---
log_info "Instalando drivers y codecs para Intel Iris Xe..."
# Instala los headers del kernel si son necesarios para compilar módulos.
KVER="$(uname -r)"
if [[ ! -d "/usr/lib/modules/${KVER}/build" ]]; then
log_info "Instalando headers de kernel..."
@@ -117,15 +254,17 @@ run_module_main() {
log_warning "Algunos paquetes OpenCL no se pudieron instalar"
}
# Crea el fichero de configuración de OpenCL para los drivers de Intel.
if [[ ! -f /etc/OpenCL/vendors/intel.icd ]] && [[ -f /usr/lib/intel-opencl/libigdrcl.so ]]; then
log_info "Configurando OpenCL para Intel..."
sudo mkdir -p /etc/OpenCL/vendors
echo "/usr/lib/intel-opencl/libigdrcl.so" | sudo tee /etc/OpenCL/vendors/intel.icd >/dev/null
fi
# Actualiza la caché de librerías compartidas.
sudo ldconfig || true
# Verificar instalación de drivers
# --- Verificación de Drivers ---
log_info "Verificando drivers Intel instalados..."
if command_exists vainfo; then
log_info "Información de VA-API:"
@@ -137,25 +276,30 @@ run_module_main() {
clinfo 2>/dev/null | grep -E "Platform Name|Device Name" || true
fi
# --- Instalación desde AUR ---
log_info "Instalando aplicaciones desde AUR..."
log_warning "Este paso puede tardar varios minutos; qt5-webengine y teamviewer descargan y compilan bastante."
if ! aur_install_packages "${AUR_PACKAGES[@]}"; then
log_warning "Algunas aplicaciones de AUR no se pudieron instalar automáticamente."
fi
# Configurar servicios
log_info "Configurando servicios..."
# --- Configuración de Servicios ---
log_info "Configurando servicios del sistema..."
# Configura GNOME Keyring para que actúe como agente de credenciales y SSH.
log_info "Configurando GNOME Keyring como agente de credenciales..."
mkdir -p "${HOME}/.config/environment.d"
cat <<'EOF' > "${HOME}/.config/environment.d/10-gnome-keyring.conf"
SSH_AUTH_SOCK=/run/user/$UID/keyring/ssh
EOF
# Habilita el servicio de GNOME Keyring para el usuario actual.
if systemctl --user enable --now gnome-keyring-daemon.socket gnome-keyring-daemon.service >/dev/null 2>&1; then
log_success "GNOME Keyring listo para gestionar contraseñas y claves SSH."
else
log_warning "No se pudo habilitar gnome-keyring-daemon en systemd de usuario. Verifica que tu sesión use systemd (--user)."
fi
# Inicia el daemon de GNOME Keyring en la sesión actual para que `ssh-add` funcione.
if command_exists gnome-keyring-daemon; then
local keyring_eval
keyring_eval="$(gnome-keyring-daemon --start --components=secrets,ssh 2>/dev/null)" || keyring_eval=""
@@ -169,21 +313,16 @@ EOF
fi
log_info "Vuelve a iniciar sesión para que las variables de entorno del keyring se apliquen."
# Busca claves SSH en ~/.ssh y las añade al agente de GNOME Keyring.
if command_exists ssh-add; then
local ssh_dir="${HOME}/.ssh"
if [[ -d "$ssh_dir" ]]; then
# Encuentra todas las claves privadas válidas.
mapfile -t ssh_private_keys < <(
find "$ssh_dir" -maxdepth 1 -type f -perm -u=r \
! -name "*.pub" \
! -name "*-cert.pub" \
! -name "known_hosts" \
! -name "known_hosts.*" \
! -name "authorized_keys" \
! -name "config" \
! -name "*.old" \
! -name "agent" \
! -name "*.bak" \
2>/dev/null
! -name "*.pub" ! -name "*-cert.pub" ! -name "known_hosts" \
! -name "known_hosts.*" ! -name "authorized_keys" ! -name "config" \
! -name "*.old" ! -name "agent" ! -name "*.bak" 2>/dev/null
)
if [[ ${#ssh_private_keys[@]} -gt 0 ]]; then
log_info "Agregando claves SSH detectadas al keyring (se solicitará la passphrase si aplica)..."
@@ -192,23 +331,20 @@ EOF
log_warning "No se puede leer la clave $(basename "$key_path"); revísala manualmente."
continue
fi
# Intenta añadir la clave al agente.
if ssh-keygen -y -f "$key_path" >/dev/null 2>&1; then
log_info "Registrando clave $(basename "$key_path")..."
local spinner_was_active=0
if [[ ${SPINNER_ACTIVE:-0} -eq 1 ]]; then
spinner_was_active=1
fi
if declare -F pause_spinner >/dev/null; then
pause_spinner
fi
if [[ ${SPINNER_ACTIVE:-0} -eq 1 ]]; then spinner_was_active=1; fi
if declare -F pause_spinner >/dev/null; then pause_spinner; fi
if SSH_AUTH_SOCK="$SSH_AUTH_SOCK" ssh-add "$key_path"; then
log_success "Clave $(basename "$key_path") añadida al keyring."
else
log_warning "No se pudo añadir la clave $(basename "$key_path")."
fi
if (( spinner_was_active )) && declare -F resume_spinner >/dev/null; then
resume_spinner
fi
if (( spinner_was_active )) && declare -F resume_spinner >/dev/null; then resume_spinner; fi
else
log_warning "La clave $(basename "$key_path") parece inválida. Se omite."
fi
@@ -223,25 +359,20 @@ EOF
log_warning "ssh-add no está disponible; no se pueden registrar claves en el keyring."
fi
# Habilitar keyd si está instalado
# Habilita los servicios de las aplicaciones instaladas.
if command_exists keyd; then
log_info "Habilitando servicio keyd..."
sudo systemctl enable keyd.service 2>/dev/null || true
sudo systemctl start keyd.service 2>/dev/null || true
sudo systemctl enable --now keyd.service 2>/dev/null || true
fi
# Habilitar logiops si está instalado
if command_exists logiops; then
log_info "Habilitando servicio logiops..."
sudo systemctl enable logiops.service 2>/dev/null || true
sudo systemctl start logiops.service 2>/dev/null || true
sudo systemctl enable --now logiops.service 2>/dev/null || true
fi
# Habilitar TeamViewer daemon si está instalado
if command_exists teamviewer; then
log_info "Habilitando servicio TeamViewer..."
sudo systemctl enable teamviewerd.service 2>/dev/null || true
sudo systemctl start teamviewerd.service 2>/dev/null || true
sudo systemctl enable --now teamviewerd.service 2>/dev/null || true
log_success "TeamViewer daemon habilitado e iniciado"
fi
@@ -249,7 +380,7 @@ EOF
return 0
}
# Ejecutar si se llama directamente
# Ejecutar si se llama directamente al script.
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
run_module_main "$@"
fi

View File

@@ -125,16 +125,26 @@ aur_install_packages() {
return 1
fi
local -a base_flags=(--noconfirm --needed --noeditmenu --nodiffmenu --nocleanmenu)
local -a base_flags=(--noconfirm --needed)
AUR_HELPER_CMD="$helper"
local status=0
case "$helper" in
yay)
"$helper" -S "${base_flags[@]}" --answerdiff None --answerclean All --answeredit None --mflags "--noconfirm" --cleanafter "${packages[@]}"
"$helper" -S "${base_flags[@]}" \
--answerdiff None \
--answerclean All \
--answeredit None \
--mflags "--noconfirm" \
--cleanafter \
"${packages[@]}"
status=$?
;;
paru)
"$helper" -S "${base_flags[@]}" --skipreview --cleanafter --mflags "--noconfirm" "${packages[@]}"
"$helper" -S "${base_flags[@]}" \
--skipreview \
--cleanafter \
--mflags "--noconfirm" \
"${packages[@]}"
status=$?
;;
*)

View File

@@ -13,6 +13,18 @@ else
exit 1
fi
# Opciones comunes para curl con timeout moderado y reintentos breves.
ZSH_CURL_TIMEOUT_OPTS=(--fail --location --silent --show-error --connect-timeout 10 --max-time 60 --retry 2 --retry-delay 2)
zsh_download_with_timeout() {
local url="$1"
local dest="$2"
if curl "${ZSH_CURL_TIMEOUT_OPTS[@]}" -o "$dest" "$url"; then
return 0
fi
return 1
}
install_zsh() {
log_step "Configuración Completa de Zsh"
@@ -55,10 +67,20 @@ install_zsh() {
else
log_warning "No se pudo instalar Oh My Posh mediante pacman ni AUR."
log_info "Descargando instalador oficial de Oh My Posh..."
if curl -fsSL https://ohmyposh.dev/install.sh | sudo bash -s -- -d /usr/local/bin; then
log_success "Oh My Posh instalado usando el script oficial."
local omp_installer
omp_installer="$(mktemp)"
if [[ -n "$omp_installer" ]] && zsh_download_with_timeout "https://ohmyposh.dev/install.sh" "$omp_installer"; then
if sudo bash "$omp_installer" -d /usr/local/bin; then
log_success "Oh My Posh instalado usando el script oficial."
else
log_error "Falló la instalación de Oh My Posh usando el script oficial."
rm -f "$omp_installer"
return 1
fi
rm -f "$omp_installer"
else
log_error "Fallo la instalación de Oh My Posh usando el script oficial."
rm -f "${omp_installer:-}"
log_error "No se pudo descargar el instalador oficial de Oh My Posh."
return 1
fi
fi
@@ -71,12 +93,25 @@ install_zsh() {
local target_ohmyzsh_dir="${target_home}/.oh-my-zsh"
if [[ ! -d "$target_ohmyzsh_dir" ]]; then
log_info "Instalando Oh My Zsh..."
# Usar RUNZSH=no para evitar que inicie un nuevo shell y CHSH=no para no cambiar el shell aún
if ! env HOME="$target_home" RUNZSH=no CHSH=no \
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended --keep-zshrc; then
log_error "Falló la instalación de Oh My Zsh."
local omz_installer
omz_installer="$(mktemp)"
if [[ -z "$omz_installer" ]]; then
log_error "No se pudo crear un archivo temporal para el instalador de Oh My Zsh."
return 1
fi
if zsh_download_with_timeout "https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh" "$omz_installer"; then
# Usar RUNZSH=no para evitar que inicie un nuevo shell y CHSH=no para no cambiar el shell aún
if ! env HOME="$target_home" RUNZSH=no CHSH=no sh "$omz_installer" --unattended --keep-zshrc; then
rm -f "$omz_installer"
log_error "Falló la instalación de Oh My Zsh."
return 1
fi
else
rm -f "$omz_installer"
log_error "No se pudo descargar el instalador de Oh My Zsh."
return 1
fi
rm -f "$omz_installer"
else
log_info "Oh My Zsh ya está instalado."
fi
@@ -115,7 +150,7 @@ install_zsh() {
local tmp_download="${target_home}/.zshrc.omarchy-tmp"
local source_file=""
if curl -fsSL "${REPO_BASE}/.zshrc" -o "$tmp_download" && [[ -s "$tmp_download" ]]; then
if zsh_download_with_timeout "${REPO_BASE}/.zshrc" "$tmp_download" && [[ -s "$tmp_download" ]]; then
source_file="$tmp_download"
log_success "Configuración .zshrc descargada desde el repositorio remoto."
else
@@ -156,7 +191,7 @@ install_zsh() {
local posh_theme_local="${SCRIPT_DIR_ROOT}/themes/catppuccin_frappe.omp.json"
mkdir -p "$posh_themes_dir"
if curl -fsSL "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/catppuccin_frappe.omp.json" -o "$theme_file"; then
if zsh_download_with_timeout "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/catppuccin_frappe.omp.json" "$theme_file"; then
chmod 644 "$theme_file" 2>/dev/null || true
log_success "Tema Catppuccin Frappe descargado en $theme_file"
else