devs/bin/path_add.sh

55 lines
No EOL
2.1 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
#Script : path_add.sh
#Apps : MRDEVS TOOLS
#Description : Add bin directory to PATH (non-persistent)
#Author : Cortana Rosero One <cortana@rosero.one>
#Generated : Created by Claude Code (claude-3-7-sonnet-20250219)
#Created : 2025/04/01 21:00:00
#Modified : 2025/04/01 21:00:00
#Version : 1.3.1
#Use Notes : Source this script to add bin directory to PATH
#==============================================================================
# Derechos de Autor 2025 Mauro Rosero P. <mauro@rosero.one>
#==============================================================================
# Este programa es software libre: usted puede redistribuirlo y/o modificarlo
# bajo los términos de la Licencia Pública Affero General de GNU tal como
# lo publica la Free Software Foundation, ya sea la versión 3 de la licencia,
# o (a su elección) cualquier versión posterior.
#
# Este programa se distribuye con la esperanza de que sea útil,
# pero SIN NINGUNA GARANTÍA; sin siquiera la garantía implícita de
# COMERCIABILIDAD o IDONEIDAD PARA UN PROPÓSITO PARTICULAR. Consulte la
# Licencia Pública Affero General de GNU para obtener más detalles.
#
# Debería haber recibido una copia de la Licencia Pública Affero General
# junto con este programa. Si no la recibió, consulte <https://www.gnu.org/licenses/>.
# Determinar la ruta base de la plataforma de desarrollo
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEVSPATH=$(cat "$SCRIPT_DIR/config/devspath.dat")
BIN_DIR="$HOME/$DEVSPATH/bin"
# Función para verificar si una ruta ya está en el PATH
function path_contains() {
local check_path="$1"
echo "$PATH" | grep -q -E "(^|:)$check_path(:|$)"
return $?
}
# Función para agregar la ruta al PATH
function add_to_path() {
local bin_path="$1"
if ! path_contains "$bin_path"; then
export PATH="$bin_path:$PATH"
echo "✅ Ruta '$bin_path' agregada al PATH"
else
echo " La ruta '$bin_path' ya está en el PATH"
fi
}
# Agregar la ruta bin al PATH
add_to_path "$BIN_DIR"
echo "✨ Los comandos de desarrollo están disponibles en esta sesión"
echo "💡 Uso: source ${BIN_DIR}/path_add.sh"