only curl, no using git
All checks were successful
CI Pipeline / shasums (push) Successful in 24s
git-sync-with-mirror / git-sync (push) Successful in 44s
CI Pipeline / build (push) Successful in 5m4s

This commit is contained in:
Jesus 2025-05-18 18:33:03 -05:00
parent 6fff4075d9
commit 3e1e5bc4e1
Signed by: heckyel
GPG Key ID: 531E723EED721D7C
5 changed files with 308 additions and 288 deletions

View File

@ -4,11 +4,11 @@ Custom Prompt Shell Settings for Bash
## Requirements ## Requirements
- wget
- curl - curl
- git
- less - less
- coreutils - coreutils
- net-tools
- unzip
## Features ## Features
@ -28,7 +28,7 @@ Custom Prompt Shell Settings for Bash
- `ii` general system information - `ii` general system information
- `proxy_on` enables proxy in terminal or tty - `proxy_on` enables proxy in terminal or tty
- `sagent_start` and `sangent_stop` to enable or disable the SSH agent (password is remembered for 432000 seconds) - `sagent_start` and `sangent_stop` to enable or disable the SSH agent (password is remembered for 432000 seconds)
- `rar2zip` convert RAR files to ZIP, use `unar` and `7z` - `rar2zip` convert RAR files to ZIP, use `unar` (`unrar`) and `7z`
- Aliases like: - Aliases like:
- `clean` clears the bash history - `clean` clears the bash history

View File

@ -4,9 +4,11 @@ Configuración personalizada del Prompt Shell para Bash
## Dependencias ## Dependencias
- wget
- curl - curl
- git - less
- coreutils
- net-tools
- unzip
## Características ## Características
@ -26,7 +28,7 @@ Configuración personalizada del Prompt Shell para Bash
- `ii` información general del sistema - `ii` información general del sistema
- `proxy_on` activa proxy en el terminal o tty - `proxy_on` activa proxy en el terminal o tty
- `sagent_start` y `sangent_stop` para activar o desactivar el agente SSH (la contraseña es recordada por 432000 segundos) - `sagent_start` y `sangent_stop` para activar o desactivar el agente SSH (la contraseña es recordada por 432000 segundos)
- `rar2zip` convierte archivos RAR a ZIP, utiliza `unar` y `7z` - `rar2zip` convierte archivos RAR a ZIP, utiliza `unar` (`unrar`) y `7z`
- Aliases como: - Aliases como:
- `clean` limpia el historial de bash - `clean` limpia el historial de bash

View File

@ -1,64 +1,87 @@
#!/bin/bash #!/bin/bash
# shellcheck source=/dev/null # shellcheck source=/dev/null
#------------------ #----------------------------
# Update functions # Check if a command exists
#------------------ #----------------------------
function _which() { function _which() {
command -v "$1" &> /dev/null command -v "$1" &> /dev/null
} }
# Check URL's #----------------------------
# --------------------- # Check if a URL is reachable
#----------------------------
function _url_exists() { function _url_exists() {
curl --output /dev/null 2>&1 -s -w "%{http_code}\n" "$1" curl --output /dev/null --silent --head --write-out "%{http_code}" "$1"
} }
#------------------
# Set working URLs
#------------------
function _urls() { function _urls() {
URL_1="https://git.fridu.us/heckyel/hyperterm" URL_1="https://git.fridu.us/heckyel/hyperterm"
URL_2="https://c.fridu.us/software/hyperterm.git" URL_2="https://c.fridu.us/software/hyperterm.git"
if [ "$(_url_exists "$URL_1")" -eq 200 ]; then if [ "$(_url_exists "$URL_1")" -eq 200 ]; then
URL="$URL_1" URL="$URL_1"
RAW="$URL_1/raw/branch/master" RAW="$URL_1/raw/branch/master"
elif [ "$(_url_exists "$URL_2")" -eq 200 ]; then elif [ "$(_url_exists "$URL_2")" -eq 200 ]; then
URL="$URL_2" URL="$URL_2"
RAW="$URL_2/plain" RAW="$URL_2/plain"
else
msg_err "El repositorio no está disponible o no hay conexión a Internet." \
"The repository is unavailable or there's no internet connection."
exit 1
fi fi
} }
# ----------------------
#----------------------------
# Download file with curl
#----------------------------
function download_file() {
local remote_path=$1
local local_path=$2
mkdir -p "$(dirname "$local_path")"
curl -Ls "$RAW/$remote_path" -o "$local_path"
}
#----------------------------
# Download _custom.sh if missing
#----------------------------
function ifexists_custom() { function ifexists_custom() {
_urls
_urls "$@" local custom_path="$HOME/.hyperterm/_custom.sh"
if [ ! -e "$custom_path" ]; then
if [ ! -e "$HOME/.hyperterm/_custom.sh" ]; then download_file "hyperterm/_custom.sh" "$custom_path"
case $1 in
wget) wget "$RAW/hyperterm/_custom.sh" -O "$HOME/.hyperterm/_custom.sh" ;;
curl) curl "$RAW/hyperterm/_custom.sh" -o "$HOME/.hyperterm/_custom.sh" ;;
git) cp -v /tmp/hyperterm/hyperterm/_custom.sh "$HOME/.hyperterm/" ;;
esac
fi fi
} }
#----------------------------
# Show progress bar
#----------------------------
function show_progress() {
case $1 in
1) printf '%s\r' "##### (33%)" ;;
2) printf '%s\r' "############# (66%)" ;;
3) printf '%s\n' "####################### (100%) done!" ;;
esac
}
#----------------------------
# Update HyperTerm environment
#----------------------------
function updbashrc() { function updbashrc() {
_urls
_urls "$@" # Step 1: Download checksum and _custom.sh
download_file "hyperterm/hyperterm.sha512" "$HOME/.hyperterm/hyperterm.sha512"
ifexists_custom
# data integration # Step 2: Verify checksum
if _which wget; then
wget -nv "$RAW/hyperterm/hyperterm.sha512" -O "$HOME/.hyperterm/hyperterm.sha512" &> /dev/null
ifexists_custom wget &> /dev/null
elif _which curl; then
curl "$RAW/hyperterm/hyperterm.sha512" -o "$HOME/.hyperterm/hyperterm.sha512" &> /dev/null
ifexists_custom curl &> /dev/null
fi
# checksum of data verification
(cd "$HOME/.hyperterm/" && sha512sum -c hyperterm.sha512 &> /dev/null) (cd "$HOME/.hyperterm/" && sha512sum -c hyperterm.sha512 &> /dev/null)
_interger=$? local _interger=$?
if _which git; then
if [[ "$_interger" -eq 0 ]]; then if [[ "$_interger" -eq 0 ]]; then
# Import colors # Load colors and print banner
_colors_bash "$@" _colors_bash "$@"
printf '%b' "${BOLD}${CYAN}" printf '%b' "${BOLD}${CYAN}"
printf '%s\n' ' __ __ ______ ' printf '%s\n' ' __ __ ______ '
@ -69,83 +92,72 @@ function updbashrc() {
printf '%s\n' ' /____/_/ ' printf '%s\n' ' /____/_/ '
printf '%s\n' ' ' printf '%s\n' ' '
printf '%b' "${BOLD}${GREY}" printf '%b' "${BOLD}${GREY}"
msg "¡Hurra! HyperTerm se ha actualizado y/o está en la versión actual." \ msg "✔️ HyperTerm se ha actualizado y/o está en la versión actual." \
"Hooray! HyperTerm has been updated and/or is at the current version." "✔️ HyperTerm has been updated and/or is at the current version."
msg "Puede reportarnos errores en https://todo.sr.ht/~heckyel/hyperterm" \ msg "Puede reportar errores en https://todo.sr.ht/~heckyel/hyperterm" \
"You can report errors issues in https://todo.sr.ht/~heckyel/hyperterm" "You can report issues at https://todo.sr.ht/~heckyel/hyperterm"
msg "Consigue tu copia de HyperTerm en: https://c.fridu.us/software/hyperterm.git" \ msg "Obtén tu copia en: https://c.fridu.us/software/hyperterm.git" \
"Get your HyperTerm copy on: https://c.fridu.us/software/hyperterm.git" "Get your copy at: https://c.fridu.us/software/hyperterm.git"
printf '%b\n' "$RESET" printf '%b\n' "$RESET"
else else
case $(_url_exists "$URL") in msg "Fallo de checksum. Re-descargando archivos desde: $URL" \
200) "Checksum failed. Re-downloading files from: $URL"
# clone '--depth=1' not support cgit show_progress 1
msg "Usando: $URL" \
"Using: $URL"
(git clone "$URL" /tmp/hyperterm/ --depth=1 &> /dev/null)
printf '%s\r' "##### (33%)"
sleep 1 sleep 1
# core
for i in autocomplete.sh colors.sh git.sh languages.sh status.sh update.sh; do
install -m644 /tmp/hyperterm/hyperterm/core/$i "$HOME/.hyperterm/core/$i"
done
# themes
for i in default.sh joy.sh light_theme.sh minterm.sh pure.sh simple.sh special.sh; do
install -m644 /tmp/hyperterm/hyperterm/themes/$i "$HOME/.hyperterm/themes/$i"
done
# tools
(cp -f /tmp/hyperterm/hyperterm/tools/* "$HOME/.hyperterm/tools/" &> /dev/null)
for i in hyperterm.sh hyperterm.sha512; do # Step 3: Core files
install -m644 /tmp/hyperterm/hyperterm/$i "$HOME/.hyperterm/$i" for f in autocomplete.sh colors.sh git.sh languages.sh status.sh update.sh; do
download_file "hyperterm/core/$f" "$HOME/.hyperterm/core/$f"
done done
(cp -f /tmp/hyperterm/.bash_profile "$HOME/" &> /dev/null)
printf '%s\r' "############# (66%)" # Step 4: Themes
(ifexists_custom git &> /dev/null) for f in default.sh joy.sh light_theme.sh minterm.sh pure.sh simple.sh special.sh; do
download_file "hyperterm/themes/$f" "$HOME/.hyperterm/themes/$f"
done
show_progress 2
sleep 1 sleep 1
(rm -fr /tmp/hyperterm/)
printf '%s\n' "####################### (100%) done!" # Step 5: Tools
source "$HOME/.bashrc" ;; for f in aliases.sh compress.sh export.sh listuser.sh network.sh proxy.sh rar2zip.sh ruby.sh ssh-agent.sh sysinfo.sh vconverter.sh virtualenv.sh; do
*) download_file "hyperterm/tools/$f" "$HOME/.hyperterm/tools/$f"
msg_err "El repo esta deshabilitado o no hay conexión a Internet" \ done
"The repo is disabled or connection failed"
return 1 ;; # Step 6: Main files
esac download_file "hyperterm/hyperterm.sh" "$HOME/.hyperterm/hyperterm.sh"
fi download_file "hyperterm/hyperterm.sha512" "$HOME/.hyperterm/hyperterm.sha512"
else download_file ".bash_profile" "$HOME/.bash_profile"
msg_err "No hay curl y git. Por favor, instale los programas para actualizar HyperTerm" \
"I couldn't find not curl and git. Please, install the programs to update HyperTerm" ifexists_custom
return 1 show_progress 3
_colors_bash "$@"
source "$HOME/.bashrc"
fi fi
} }
#------------------------------------
# Overwrite _custom.sh interactively
#------------------------------------
function updbashrc_custom() { function updbashrc_custom() {
_urls "$@" _urls
case $(_url_exists "$URL") in if [ "$(_url_exists "$URL")" -eq 200 ]; then
200) while true; do
while true
do
function _copy_c() {
if _which wget; then
wget "$RAW/hyperterm/_custom.sh" -O "$HOME/.hyperterm/_custom.sh"; source "$HOME/.bashrc"
elif _which curl; then
curl "$RAW/hyperterm/_custom.sh" -o "$HOME/.hyperterm/_custom.sh"; source "$HOME/.bashrc"
fi
}
question=$(msg "¿Estás seguro de sobre-escribir _custom.sh? [s/N]: " \ question=$(msg "¿Estás seguro de sobre-escribir _custom.sh? [s/N]: " \
"Are you sure to overwrite _custom.sh? [y/N]: ") "Are you sure to overwrite _custom.sh? [y/N]: ")
read -r -p "$question" input read -r -p "$question" input
case $input in case "$input" in
[sS]|[yY]) _copy_c "$@"; break ;; [yY]|[sS])
download_file "hyperterm/_custom.sh" "$HOME/.hyperterm/_custom.sh"
source "$HOME/.bashrc"
break ;;
[nN]|"") break ;; [nN]|"") break ;;
*) msg "Por favor responde sí o no" \ *) msg "Por favor responde sí o no." \
"Please answer yes or no.";; "Please answer yes or no." ;;
esac esac
done ;; done
*) else
msg_err "El repo esta deshabilitado o no hay conexión a Internet" \ msg_err "El repositorio no está disponible o no hay conexión a Internet." \
"The repo is disabled or connection failed" "The repository is unavailable or there's no internet connection."
return 1 return 1
;; fi
esac
} }

View File

@ -1,5 +1,5 @@
cdfe049ec07f02a1893cda29c13085d06709e09a30b0c2e1111585278315f03139d61080c883cb3fd87f2bf64e05d9b5e5eaaad84c97ced890d83c73eb399fcb ../.bash_profile cdfe049ec07f02a1893cda29c13085d06709e09a30b0c2e1111585278315f03139d61080c883cb3fd87f2bf64e05d9b5e5eaaad84c97ced890d83c73eb399fcb ../.bash_profile
42fadfdc8adee2825df79ae7ee449fcc54c383a114fa3a28bab66adae9ce026078dd793e3b5e2fe918cb088fbfc0c955828cbcf0b28f977f2904e8b19a2019fd ./core/update.sh 57bf0f09423414323ada7c518e2865db8651aa1b239fb5d89d3eb0687d4c3f5d8fe66fe48c6988ff50db0f54f67edfd36c4ea3193fe909c2349eee4a3efcdaa6 ./core/update.sh
1cfba599047d84a17ff92b695ebf527a505a30acc9ec21a2b9f410a7ea6dde4b23b5cf62e557d82f2fe9a8980649942424b879ca53baae4d4cb3057681baa7b6 ./core/colors.sh 1cfba599047d84a17ff92b695ebf527a505a30acc9ec21a2b9f410a7ea6dde4b23b5cf62e557d82f2fe9a8980649942424b879ca53baae4d4cb3057681baa7b6 ./core/colors.sh
065cfa39f1b4312ed275ad1039827a24f703176c653a8d27303d145f9d389a60ec5b3a9eb167e060cc6fd093b9c03cfb1a8b70254d444fbc6e62e2297d88b310 ./core/status.sh 065cfa39f1b4312ed275ad1039827a24f703176c653a8d27303d145f9d389a60ec5b3a9eb167e060cc6fd093b9c03cfb1a8b70254d444fbc6e62e2297d88b310 ./core/status.sh
2036a79215a5434e31f3406bea3f2ffa7e94ffef86c2d1ceb8865db29f19fe7f342f9cab93288f57c75daed36ef146f85d15f8d633931a27d55c3983f55ef15b ./core/git.sh 2036a79215a5434e31f3406bea3f2ffa7e94ffef86c2d1ceb8865db29f19fe7f342f9cab93288f57c75daed36ef146f85d15f8d633931a27d55c3983f55ef15b ./core/git.sh

View File

@ -27,53 +27,88 @@ function msg_err() {
esac esac
} }
# Check Requirements # Check Requirements
# ------------------- # -------------------
programs=("wget" "curl" "git" "less") function install_package() {
local pkg="$1"
local sudo_cmd=""
local distro=""
local os_data
case "$(id -u)" in
0) sudo_cmd="" ;;
*)
case "$(command -v doas 2>/dev/null)" in
"") sudo_cmd="sudo" ;;
*) sudo_cmd="doas" ;;
esac
;;
esac
os_data="$(cat /etc/*release 2>/dev/null | tr '[:upper:]' '[:lower:]')"
case "$os_data" in
*id=artix*|*id=arch*|*id=hyperbola*) distro="arch" ;;
*id_like=arch*) distro="arch" ;;
*id=debian*|*id=ubuntu*|*id_like=debian*) distro="debian" ;;
*)
msg_err "Sistema operativo no soportado automáticamente." \
"Operating system not automatically supported."
exit 1
;;
esac
case "$distro" in
arch)
$sudo_cmd pacman -Sy --noconfirm "$pkg"
;;
debian)
$sudo_cmd apt-get update
$sudo_cmd apt-get install -y "$pkg"
;;
esac
}
programs=("curl" "less" "ls" "netstat" "unzip")
for program in "${programs[@]}"; do for program in "${programs[@]}"; do
if ! command -v "$program" &>/dev/null; then if ! command -v "$program" &>/dev/null; then
msg_err "$program no está instalado." \ case "$program" in
"$program is not installed" && exit 1 netstat) pkg="net-tools" ;;
ls) pkg="coreutils" ;;
*) pkg="$program" ;;
esac
msg "Instalando dependencia: $pkg" "Installing dependency: $pkg"
install_package "$pkg"
fi fi
done done
# Check URL's # Check URLs availability
# ----------- # -----------------------
function _which() {
command -v "$1" &> /dev/null
}
function _url_exists() { function _url_exists() {
if _which wget; then
if wget --spider "$1" 2>/dev/null; then
return 0 # URL 'ok'
else
return 1 # URL 'fail'
fi
elif _which curl; then
if curl --output /dev/null --silent --head --fail "$1"; then if curl --output /dev/null --silent --head --fail "$1"; then
return 0 # URL 'ok' return 0
else else
return 1 # URL 'fail' return 1
fi
fi fi
} }
function _urls() { function _urls() {
URL_1="https://git.fridu.us/heckyel/hyperterm" URL_1="https://git.fridu.us/heckyel/hyperterm/archive/master.zip"
URL_2="https://c.fridu.us/heckyel/hyperterm" URL_2="https://c.fridu.us/software/hyperterm.git/snapshot/hyperterm-master.zip"
if [[ $(_url_exists "$URL_1") -eq 0 ]]; then if _url_exists "$URL_1"; then
URL="$URL_1" URL="$URL_1"
elif [[ $(_url_exists "$URL_2") -eq 0 ]]; then elif _url_exists "$URL_2"; then
URL="$URL_2" URL="$URL_2"
else
msg_err "No se pudo acceder a las URLs de HyperTerm." \
"Could not access HyperTerm URLs."
exit 1
fi fi
} }
# -----------
# Show how to use this installer # Show usage
# ------------------------------ # -----------
function show_usage() { function show_usage() {
msg "\n$0: Instalar HyperTerm" \ msg "\n$0: Instalar HyperTerm" \
"\n$0: Install HyperTerm" "\n$0: Install HyperTerm"
@ -83,178 +118,148 @@ function show_usage() {
"Arguments:" "Arguments:"
msg "--help (-h): Muestra mensaje de ayuda" \ msg "--help (-h): Muestra mensaje de ayuda" \
"--help (-h): Display this help message" "--help (-h): Display this help message"
msg "--silent (-s): Instala la configuración predeterminada sin solicitar entrada" \ msg "--silent (-s): Instala sin pedir interacción" \
"--silent (-s): Install default settings without prompting for input" "--silent (-s): Install silently"
msg "--no-modify-config (-n): No modifica el archivo de configuración existente" \ msg "--no-modify-config (-n): No modifica archivo config" \
"--no-modify-config (-n): Do not modify existing config file" "--no-modify-config (-n): Do not modify config file"
exit 0; exit 0
} }
# Clone # Download and unzip archive
#------ # --------------------------
function clone_new() { function download_and_unzip() {
_urls "$@" _urls
# clone msg "\e[1;32m==>\e[0m\033[1m Descargando HyperTerm... \e[m" \
msg "\e[1;32m==>\e[0m\033[1m Clonando hyperterm... \e[m" \ "\e[1;32m==>\e[0m\033[1m Downloading HyperTerm... \e[m"
"\e[1;32m==>\e[0m\033[1m Cloning hyperterm... \e[m"
git clone "$URL" "/tmp/hyperterm/" --depth=1
# copy TMP_DIR=$(mktemp -d /tmp/hyperterm.XXXXXX)
msg "\e[1;32m==>\e[0m\033[1m Copiando hyperterm... \e[m" \ ZIP_FILE="$TMP_DIR/hyperterm.zip"
"\e[1;32m==>\e[0m\033[1m Copying hyperterm... \e[m"
if [[ "$silent" ]]; then curl -L -o "$ZIP_FILE" "$URL"
install -d -m755 "$HOME/.hyperterm/"
cp -r /tmp/hyperterm/hyperterm/* "$HOME/.hyperterm/" msg "\e[1;32m==>\e[0m\033[1m Descomprimiendo HyperTerm... \e[m" \
install -m644 /tmp/hyperterm/.bash_profile "$HOME/" "\e[1;32m==>\e[0m\033[1m Unzipping HyperTerm... \e[m"
install -d -m755 "$HOME/.hyperterm/template/"
install -m644 /tmp/hyperterm/template/bash_profile.template.bash "$HOME/.hyperterm/template/" unzip -q "$ZIP_FILE" -d "$TMP_DIR"
else # The unzip folder will be something like hyperterm-master or hyperterm-master.zip contents
install -d -m755 -v "$HOME/.hyperterm/"
cp -rv /tmp/hyperterm/hyperterm/* "$HOME/.hyperterm/" # Move extracted files to ~/.hyperterm
install -m644 -v /tmp/hyperterm/.bash_profile "$HOME/" mkdir -p "$HOME/.hyperterm"
install -d -m755 -v "$HOME/.hyperterm/template/" # Find extracted dir
install -m644 -v /tmp/hyperterm/template/bash_profile.template.bash "$HOME/.hyperterm/template/" EXTRACTED_DIR=$(find "$TMP_DIR" -mindepth 1 -maxdepth 1 -type d | head -n 1)
cp -r "$EXTRACTED_DIR/hyperterm"/* "$HOME/.hyperterm/"
# Copy .bash_profile and template files if exist
if [[ -f "$EXTRACTED_DIR/.bash_profile" ]]; then
cp "$EXTRACTED_DIR/.bash_profile" "$HOME/"
fi fi
mkdir -p "$HOME/.hyperterm/template"
if [[ -f "$EXTRACTED_DIR/template/bash_profile.template.bash" ]]; then
cp "$EXTRACTED_DIR/template/bash_profile.template.bash" "$HOME/.hyperterm/template/"
fi
# Clean temp
rm -rf "$TMP_DIR"
} }
function clean_temp() { # Backup and install
# clean up temp files # ------------------
msg "\e[1;32m==>\e[0m\033[1m Limpiando archivos temporales... \e[m" \ function backup_and_install() {
"\e[1;32m==>\e[0m\033[1m Clean up temp files... \e[m" download_and_unzip
if [[ "$silent" ]]; then
rm -rf /tmp/hyperterm/
if [[ -f "$HOME/.hyperterm/template/bash_profile.template.bash" ]]; then
rm -fr "$HOME/.hyperterm/template/"
fi
else
rm -rfv /tmp/hyperterm/
if [[ -f "$HOME/.hyperterm/template/bash_profile.template.bash" ]]; then
rm -frv "$HOME/.hyperterm/template/"
fi
fi
}
# Back up existing profile and create new one for hyperterm test -w "$HOME/$CONFIG_FILE" && cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
# ---------------------------------------------------------
function backup_new() {
clone_new "$@"
test -w "$HOME/$CONFIG_FILE" &&
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
msg "\033[0;36mTu archivo original $CONFIG_FILE ha sido respaldado a $CONFIG_FILE.bak \033[0m" \ msg "\033[0;36mTu archivo original $CONFIG_FILE ha sido respaldado a $CONFIG_FILE.bak \033[0m" \
"\033[0;36mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak \033[0m" "\033[0;36mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak \033[0m"
sed "s|{{HYPER_BASH}}|$HYPER_BASH|" "$HYPER_BASH/.hyperterm/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" sed "s|{{HYPER_BASH}}|$HYPER_BASH|" "$HOME/.hyperterm/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE"
msg "\033[0;36mPlantilla copiada de $CONFIG_FILE dentro de ~/$CONFIG_FILE \033[0m" \
"\033[0;36mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE \033[0m" msg "\033[0;36mPlantilla copiada a ~/$CONFIG_FILE \033[0m" \
clean_temp "$@" "\033[0;36mTemplate copied to ~/$CONFIG_FILE \033[0m"
} }
# Parse args
# ----------
for param in "$@"; do for param in "$@"; do
shift shift
case "$param" in case "$param" in
"--help") set -- "$@" "-h" ;; "--help") set -- "$@" "-h" ;;
"--silent") set -- "$@" "-s" ;; "--silent") set -- "$@" "-s" ;;
"--no-modify-config") set -- "$@" "-n" ;; "--no-modify-config") set -- "$@" "-n" ;;
*) set -- "$@" "$param" *) set -- "$@" "$param" ;;
esac esac
done done
OPTIND=1 OPTIND=1
while getopts "hsn" opt while getopts "hsn" opt; do
do
case "$opt" in case "$opt" in
"h") show_usage;; h) show_usage ;;
"s") silent=true ;; s) silent=true ;;
"n") no_modify_config=true ;; n) no_modify_config=true ;;
"?") show_usage >&2;; ?) show_usage >&2 ;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
HYPER_BASH="$(cd "$(dirname "$0")" && pwd)" # Setup config file based on OS
case "$OSTYPE" in
case $OSTYPE in darwin*) CONFIG_FILE=".bash_profile" ;;
darwin*) *) CONFIG_FILE=".bashrc" ;;
CONFIG_FILE=.bash_profile
;;
*)
CONFIG_FILE=.bashrc
;;
esac esac
BACKUP_FILE=$CONFIG_FILE.bak HYPER_BASH="$(cd "$(dirname "$0")" && pwd)"
msg "Instalando HyperTerm" \
"Installing HyperTerm"
if ! [[ "$silent" ]] && ! [[ "$no_modify_config" ]]; then
if [ -e "$HOME/$BACKUP_FILE" ]; then
msg_err "\033[0;36mEl archivo de respaldo ya existe. Asegúrese de hacer una copia de seguridad de su .bashrc antes de ejecutar esta instalación. \033[0m" \
"\033[0;36mBackup file already exists. Make sure to backup your .bashrc before running this installation. \033[0m"
while ! [ "$silent" ]; do
question=$(msg "¿Desea sobrescribir la copia de seguridad existente? Esto eliminará su archivo de copia de seguridad existente ($HOME/$BACKUP_FILE) [s/N] " \
"Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] ")
read -e -n 1 -r -p "$question" RESP msg "Instalando HyperTerm" "Installing HyperTerm"
case $RESP in
[yY]|[sS]) if ! [[ "$silent" ]] && ! [[ "$no_modify_config" ]]; then
break if [[ -e "$HOME/$CONFIG_FILE.bak" ]]; then
;; msg_err "\033[0;36mArchivo de respaldo ya existe. Haz backup antes de instalar.\033[0m" \
[nN]|"") "\033[0;36mBackup file already exists. Please backup before installing.\033[0m"
msg "\033[91mInstalación interrumpida. Por favor vuelve pronto!\033[m" \ while true; do
"\033[91mInstallation aborted. Please come back soon!\033[m" read -e -n 1 -r -p "$(msg "¿Sobrescribir backup? [s/N] " "Overwrite backup? [y/N] ") " RESP
exit 1 case "$RESP" in
;; [yYsS]) break ;;
*) [nN]|"") msg "Instalación abortada." "Installation aborted."; exit 1 ;;
msg "\033[91mPor favor elija sí o no.\033[m" \ *) msg "Elige sí o no." "Choose y or n." ;;
"\033[91mPlease choose y or n.\033[m"
;;
esac esac
done done
fi fi
while ! [ "$silent" ]; do while true; do
question=$(msg "¿Le gustaría conservar su configuración de $CONFIG_FILE y agregar plantillas de HyperTerm al final? [s/N] " \ read -e -n 1 -r -p "$(msg "¿Conservar $CONFIG_FILE y añadir plantilla HyperTerm al final? [s/N] " "Keep $CONFIG_FILE and append HyperTerm template? [y/N] ") " choice
"Would you like to keep your config $CONFIG_FILE and append HyperTerm templates at the end? [y/N] ") case "$choice" in
read -e -n 1 -r -p "$question" choice [yYsS])
case $choice in download_and_unzip "$@"
[yY]|[sS]) test -w "$HOME/$CONFIG_FILE" && cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
clone_new "$@" msg "\033[0;36mRespaldo creado en $CONFIG_FILE.bak \033[0m" "\033[0;36mBackup created at $CONFIG_FILE.bak \033[0m"
test -w "$HOME/$CONFIG_FILE" && (sed "s|{{HYPER_BASH}}|$HYPER_BASH|" "$HOME/.hyperterm/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE"
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && msg "\033[0;36mPlantilla HyperTerm añadida a $CONFIG_FILE\033[0m" "\033[0;36mHyperTerm template added to $CONFIG_FILE\033[0m"
msg "\033[0;36mTu archivo original $CONFIG_FILE ha sido respaldado a $CONFIG_FILE.bak \033[0m" \
"\033[0;36mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak \033[0m"
(sed "s|{{HYPER_BASH}}|$HYPER_BASH|" "$HYPER_BASH/.hyperterm/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE"
msg "\033[0;36mla plantilla HyperTerm ha sido agregada a $CONFIG_FILE\033[0m" \
"\033[0;36mHyperTerm template has been added to your $CONFIG_FILE\033[0m"
clean_temp "$@"
break break
;; ;;
[nN]|"") [nN]|"")
backup_new "$@" backup_and_install "$@"
break break
;; ;;
*) *)
msg "\033[91mPor favor elija sí o no.\033[m" \ msg "Elige sí o no." "Choose y or n."
"\033[91mPlease choose y or n.\033[m"
;; ;;
esac esac
done done
elif [[ "$silent" ]] && ! [[ "$no_modify_config" ]]; then elif [[ "$silent" ]] && ! [[ "$no_modify_config" ]]; then
# backup/new by default backup_and_install "$@"
backup_new "$@"
fi fi
echo "" echo ""
msg "\e[1;32m==>\e[0m\033[1m Instalación finalizada con éxito! Disfrute HyperTerm! \e[m" \ msg "\e[1;32m==>\e[0m\033[1m Instalación finalizada con éxito! Disfruta HyperTerm! \e[m" \
"\e[1;32m==>\e[0m\033[1m Installation finished successfully! Enjoy HyperTerm! \e[m" "\e[1;32m==>\e[0m\033[1m Installation finished successfully! Enjoy HyperTerm! \e[m"
msg "\033[0;36mPara comenzar a usarlo, abra una nueva pestaña o haga 'source $HOME/$CONFIG_FILE'.\033[0m" \ msg "\033[0;36mPara empezar, abre una nueva pestaña o haz 'source $HOME/$CONFIG_FILE'.\033[0m" \
"\033[0;36mTo start using it, open a new tab or 'source $HOME/$CONFIG_FILE'.\033[0m" "\033[0;36mTo start, open a new tab or 'source $HOME/$CONFIG_FILE'.\033[0m"
echo "" echo ""
msg "¡Muchas gracias! por instalar" \ msg "¡Gracias por instalar!" "Thank you for installing!"
"Thank you! for install"
echo -e '\033[0;36m __ __ ______ ' echo -e '\033[0;36m __ __ ______ '
echo -e '\033[0;36m / / / /_ ______ ___ ____/_ __/__ _________ ___ ' echo -e '\033[0;36m / / / /_ ______ ___ ____/_ __/__ _________ ___ '
echo -e '\033[0;36m / /_/ / / / / __ \/ _ \/ ___// / / _ \/ ___/ __ `__ \ ' echo -e '\033[0;36m / /_/ / / / / __ \/ _ \/ ___// / / _ \/ ___/ __ `__ \ '
@ -262,7 +267,8 @@ echo -e '\033[0;36m / __ / /_/ / /_/ / __/ / / / / __/ / / / / / / / '
echo -e '\033[0;36m /_/ /_/\__, / .___/\___/_/ /_/ \___/_/ /_/ /_/ /_/ ' echo -e '\033[0;36m /_/ /_/\__, / .___/\___/_/ /_/ \___/_/ /_/ /_/ /_/ '
echo -e '\033[0;36m /____/_/ ' echo -e '\033[0;36m /____/_/ '
echo -e '\033[m' echo -e '\033[m'
msg "Para evitar problemas y mantener su shell, habilite solo las funciones que realmente desea utilizar desde $HOME/.hyperterm/_custom.sh" \
"To avoid issues and to keep your shell lean, please enable only features you really want to use from $HOME/.hyperterm/_custom.sh" msg "Para evitar problemas, activa solo las funciones que uses en $HOME/.hyperterm/_custom.sh" \
msg "Puede reportarnos errores en \033[0;36mhttps://todo.sr.ht/~heckyel/hyperterm \033[0m" \ "To avoid issues, enable only the features you want from $HOME/.hyperterm/_custom.sh"
"You can report errors issues in \033[0;36mhttps://todo.sr.ht/~heckyel/hyperterm \033[0m" msg "Puedes reportar errores en \033[0;36mhttps://todo.sr.ht/~heckyel/hyperterm \033[0m" \
"You can report issues at \033[0;36mhttps://todo.sr.ht/~heckyel/hyperterm \033[0m"