Actualización

This commit is contained in:
perro tuerto 2023-06-18 10:21:50 -07:00
parent c11c3e40e6
commit 2e8f0b1864
1 changed files with 82 additions and 9 deletions

View File

@ -169,7 +169,7 @@ actualizar () {
}
actualizar-help () {
echo "actualizar: utilidad para hacer actualizaciones.
echo "actualizar: utilidad para hacer actualizaciones.
Uso:
actualizar [OPT]
@ -211,6 +211,67 @@ desinstalar () {
fi
}
### Gestión del home
home () {
if [ -d "$HOME/.git" ]; then
case $1 in
estado | status)
git -C $HOME status
;;
editar | edit)
e $HOME/.gitignore
;;
guardar | save)
git -C $HOME add .
git -C $HOME commit -m "Actualización"
;;
empujar | push)
if output=$(git -C $HOME status --porcelain) && [ ! -z "$output" ]; then
home guardar
fi
unset output
git -C $HOME pushall
;;
-h | --help | help | ayuda)
home-help ;;
*)
if [ -z "$1" ]; then
echo-error "al menos un argumento es necesario; por ejemplo 'home -h'"
else
echo-error "comando '$1' inválido"
fi
;;
esac
else
echo-error "el home '$HOME' no es un directorio git"
fi
}
home-help () {
echo "home: utilidad para gestionar el home.
Home: $HOME
Estado: $(if [ -d "$HOME/.git" ]; then echo "OK"; else echo "requiere ser un repositorio git"; fi)
Uso:
home [OPT]
Opciones:
estado | status Muestra el estado del home.
editar | edit Edita el archivo .gitignore del home.
guardar | save Guarda el estado del home.
empujar | push Empuja el estado del home al repositorio.
-h | --help | help | ayuda Despliega esta ayuda.
Ejemplos:
home estado
home editar
home guardar
home empujar
home -h"
}
### Gestión de alias
aliases () {
@ -229,9 +290,9 @@ aliases () {
;;
editar | edit)
if [ -f "$OZSH_ALIAS" ]; then
v $OZSH_ALIAS
e $OZSH_ALIAS
else
v $BASH_ALIAS
e $BASH_ALIAS
fi
;;
empujar | push)
@ -246,8 +307,7 @@ aliases () {
git -C $(parent $RLOC_ALIAS) pushall
recargar
else
echo "ERROR: No se pudo empujar al repositorio; no existe el archivo '$RLOC_ALIAS'"
exit 1
echo-error "no se pudo empujar al repositorio; no existe el archivo '$RLOC_ALIAS'"
fi
;;
enlazar | link)
@ -271,7 +331,7 @@ aliases () {
}
aliases-help () {
echo "aliases: utilidad para hacer gestionar alias.
echo "aliases: utilidad para hacer gestionar alias.
Uso:
aliases [OPT]
@ -378,7 +438,7 @@ md () {
}
md-help () {
echo "md: utilidad para hacer gestionar archivos Markdown.
echo "md: utilidad para hacer gestionar archivos Markdown.
Uso:
md [OPT]
@ -416,7 +476,7 @@ check-venv () {
if [ -f "$curr/$VENV/bin/activate" ]; then
source $curr/$VENV/bin/activate
elif [[ $(parent $1) != "/" ]]; then
check-venv $(parent $1)
check-venv $(parent $1)
else
type deactivate &>/dev/null && deactivate
fi
@ -439,6 +499,19 @@ cd () {
check-venv
}
## Modifica comportamiento de git
git () {
if [ "$#" -lt 3 ] && [ "$1" = "push" ] && ( [ -z "$2" ] || [ "$2" = "--tags" ] ); then
/usr/bin/git pushall
if [ "$2" = "--tags" ]; then
/usr/bin/git pushtags
fi
else
/usr/bin/git $@
fi
}
## Embellece y verifica código
pymp () {
@ -456,7 +529,7 @@ pymp () {
}
pymp-help () {
echo "pymp: utilidad para enchular código de Python.
echo "pymp: utilidad para enchular código de Python.
Uso:
pymp [OPT] [FILE|DIR]