Remaniement : ré-écriture de updateall

This commit is contained in:
Hippolyte Chauvin 2023-06-04 19:38:42 +02:00
parent 05bd37c8e4
commit 8e59d066dc
5 changed files with 27 additions and 20 deletions

42
bin/updateall Executable file → Normal file
View file

@ -1,28 +1,32 @@
#!/bin/bash
# Variable
commands_d="${HOME}/.local/share/updateall/commands.d"
# Variables
realpath="$(readlink -f "$0")"
# Function
# Create a clear separator, adapts to the screen size
function separator {
local separator=""
# cd
cd "$(dirname "$realpath")/../share/$(basename "$realpath")" || exit
unset realpath
local name="$1" ; shift
local char="${1:-=}"; shift
(( cols = $(tput cols) / 3 ))
while [[ ${#separator} -le "$cols" ]]; do
separator+="$char"
# Fonction pour fabriquer une ligne de la longueur d'un tiers du terminal
makeline() {
local cols line
cols="$(($(tput cols) / 3))"
while [ "${#line}" -lt "$cols" ]; do
line="${line}${1}"
done
printf '\n%s\n\t%s\n%s\n' "$separator" "$name" "$separator"
printf %s "$line"
}
# Loop
for pm in "${commands_d}/"*; do
separator "$(basename "$pm")"
# shellcheck source=/dev/null
source "$pm"
# Fonction pour afficher un séparateur
separator() {
local line
line="$(makeline '=')"
printf '\n%s\n\t%s\n%s\n' "$line" "$*" "$line"
}
# Procédure principale
for i in ./commands.d/*; do
separator "$(basename "$i")"
"$i"
done

View file

@ -1,3 +1,4 @@
#!/bin/sh
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove

View file

@ -1,3 +1,3 @@
#!/bin/sh
sudo docker images --format '{{.Repository}}' | xargs -L 1 sudo docker pull
sudo docker image prune

View file

@ -1,3 +1,4 @@
#!/bin/sh
if pushd ~/Git; then
for repo in *; do
pushd "$repo"

View file

@ -1,2 +1,3 @@
#!/bin/sh
yay -Fy
yay