dotfiles/bin/updateall

29 lines
569 B
Text
Raw Normal View History

2023-04-13 00:04:20 +02:00
#!/bin/bash
# Variable
2023-04-13 00:57:54 +02:00
commands_d="${HOME}/.local/share/updateall/commands.d"
2023-04-13 00:04:20 +02:00
# Function
# Create a clear separator, adapts to the screen size
function separator {
2023-04-13 00:57:54 +02:00
local separator=""
local name="$1" ; shift
local char="${1:-=}"; shift
2023-04-13 00:04:20 +02:00
(( cols = $(tput cols) / 3 ))
2023-04-13 00:57:54 +02:00
while [[ ${#separator} -le "$cols" ]]; do
2023-04-13 00:04:20 +02:00
separator+="$char"
done
2023-04-13 00:57:54 +02:00
printf '\n%s\n\t%s\n%s\n' "$separator" "$name" "$separator"
2023-04-13 00:04:20 +02:00
}
# Loop
2023-04-13 00:57:54 +02:00
for pm in "${commands_d}/"*; do
2023-04-13 00:04:20 +02:00
separator "$(basename "$pm")"
2023-05-14 16:02:54 +02:00
# shellcheck source=/dev/null
2023-04-13 00:04:20 +02:00
source "$pm"
done