9 Commits

Author SHA1 Message Date
fatalerrors
39a7e7b40f version bump 2026-03-05 11:56:15 +01:00
fatalerrors
6d5d872b71 add a missing fi 2026-03-05 11:49:10 +01:00
fatalerrors
128cfe8c87 improved upgrade system, version bump 2026-03-05 11:25:05 +01:00
fatalerrors
e1c2705fdd added ppu and ppn 2026-03-05 11:20:23 +01:00
fatalerrors
368bc11acf add many compression format to utaz 2026-03-05 10:55:17 +01:00
fatalerrors
a068d57ba5 utaz finally work with many formats, with optimizations 2026-03-05 10:24:25 +01:00
fatalerrors
ffee8c2e47 added help to rain, fixed french comments 2026-03-04 16:17:36 +01:00
geoffray.levasseur
9ff5792790 configurable rain 2026-03-04 15:55:11 +01:00
root
6a2d9b0fee adaptation to trixie and excalibur 2025-11-19 14:35:40 +01:00
10 changed files with 331 additions and 45 deletions

View File

@@ -7,6 +7,17 @@ Current version from Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
------------------------------------------------------------------------------
Version history:
------------------------------------------------------------------------------
# 05/03/2026 v3.6.1
Fix a typo in compress.sh
# 05/03/2026 v3.6.0
Improved utaz to make it multiformat with lot of it
Introduced ppu and ppn
Improved update system
# 04/03/2026 v3.5.0
rain has now configurable speed and color
showinfo adapted to fastfetch, replacing neofetch
# 24/02/2022 v3.3.1
Fixed version detection

View File

@@ -39,8 +39,105 @@
# ------------------------------------------------------------------------------
utaz()
{
_ununzip()
{
unzip -o "$1" -d "$2" >/dev/null 2>&1
}
_untar()
{
tar -xf "$1" -C "$2"
}
_ungzip()
{
tar -xzf "$1" -C "$2"
}
_unbzip2()
{
tar -xjf "$1" -C "$2"
}
_unxz()
{
tar -xJf "$1" -C "$2"
}
_unlzop()
{
lzop -d "$1" -o "$2/$(basename "${1%.*}")"
}
_unlzip()
{
if command -v plzip >/dev/null 2>&1; then
plzip -d -c "$1" > "$2/$(basename "${1%.*}")"
else
lzip -d -c "$1" > "$2/$(basename "${1%.*}")"
fi
}
_ununrar()
{
unrar x -o+ "$1" "$2/" >/dev/null 2>&1
}
_ununarj()
{
unarj e "$1" "$2/" >/dev/null 2>&1
}
_unlza()
{
# lha typically extracts into the current directory
# We ensure it hits the target directory
(cd "$2" && lha -x "../$1") >/dev/null 2>&1
}
_ununace()
{
unace x "$1" "$2/" >/dev/null 2>&1
}
_un7z()
{
7z x "$1" -o"$2/" >/dev/null 2>&1
}
_unzstd()
{
# Zstd decompresses files directly, often requiring tar for archives
tar --zstd -xf "$1" -C "$2"
}
_uncpio()
{
# CPIO requires careful directory handling
(cd "$2" && cpio -id < "../$1") >/dev/null 2>&1
}
_uncabextract()
{
# Requires 'cabextract' package
cabextract "$1" -d "$2/" >/dev/null 2>&1
}
_undeb()
{
# Extracts data content from a Debian package
dpkg-deb -x "$1" "$2/" >/dev/null 2>&1
}
_unrpm()
{
# Extracts CPIO-based payload from an RPM package
# Needs rpm2cpio and cpio
rpm2cpio "$1" | (cd "$2/" && cpio -idmv) >/dev/null 2>&1
}
for opt in $@; do
case $opt in
case ${opt} in
"-h" | "--help")
echo "utaz: uncompress all the given files and/or the ones found in the given"
echo " directories creating an host directory where needed."
@@ -76,62 +173,138 @@ utaz()
*)
# The ${opt%/} writing is to remove trailing / if any
local LIST="$LIST ${opt%/}"
local LIST="${LIST} ${opt%/}"
;;
esac
done
[[ $createdir && $nodir ]] && \
[[ -n ${createdir} && -n ${nodir} ]] && \
disp E "The --create-dir and --no-dir options are mutually exclusive."
[[ ! $LIST ]] && local LIST="."
for zitem in $LIST; do
shopt -s nullglob
local zips=("$zitem"/*.zip)
shopt -u nullglob
[[ ${#zips[@]} -eq 0 ]] && \
disp W "$zitem contains no supported archive file, skipping." && \
[[ -z ${LIST} ]] && local LIST="."
for zitem in ${LIST}; do
for f in "${zitem}"/*; do
local dir="${f%.*}"
local extractor=""
case "$f" in
*.zip)
extractor="_ununzip"
;;
*.tar.gz|*.tgz)
extractor="_ungzip"
;;
*.tar.bz2)
extractor="_unbzip2"
;;
*.tar.xz)
extractor="_unxz"
;;
*.tar.lz)
extractor="_unlzop"
;;
*.tar)
extractor="_untar"
;;
*.rar)
extractor="_ununrar"
;;
*.arj)
extractor="_ununarj"
;;
*.lzh|*.lha)
extractor="_unlha"
;;
*.ace)
extractor="_ununace"
;;
*.7z)
extractor="_un7z"
;;
*.zst)
extractor="_unzstd"
;;
*.cpio)
extractor="_uncpio"
;;
*.cab)
extractor="_uncabextract"
;;
*.deb)
extractor="_undeb"
;;
*.rpm)
extractor="_unrpm"
;;
*)
disp I "File ${f} is not a supported archive, skipping."
continue
;; # Skip non-archive files
esac
for f in "$zitem"/*.zip; do
disp I "Processing archive $f... "
local dir=${f::-4}
# Verify binary existence
local cmd=${extractor//_un/}
if [[ $cmd == "deb" ]]; then
command -v dpkg-deb >/dev/null 2>&1 || {
disp E "The program 'dpkg-deb' is not installed, aborting."
continue
}
elif [[ $cmd == "rpm" ]]; then
command -v rpm2cpio >/dev/null 2>&1 || {
disp E "The program 'rpm2cpio' is not installed, aborting."
continue
}
command -v cpio >/dev/null 2>&1 || {
disp E "The program 'cpio' is not installed, aborting."
continue
}
else
command -v ${cmd} >/dev/null 2>&1 || {
disp E "Binary ${cmd} necessary to extract ${f} is missing."
continue
}
fi
mkdir -p "$dir"
disp I "Processing archive ${f} with ${extractor}..."
mkdir -p "${dir}"
[[ $? -gt 0 ]] &&
disp E "The filesystem can't create directories, exit!" &&
return 1
unzip -o "$f" -d "$dir" >/dev/null 2>&1
${extractor} "${f}" "${dir}"
case $? in
0)
[[ $willrm ]] && rm -f "$f" && disp I "File $zitem/$f deleted."
[[ -n ${willrm} ]] &&
rm -f "${f}" && disp I "File ${zitem}/${f} deleted."
;;
1)
disp W "Compression program returned a warning: deletion canceled."
;;
*)
disp E "The zip file seems corrupted, failed."
rm -rf "$dir" >/dev/null 2>&1
rm -rf "${dir}" >/dev/null 2>&1
continue
;;
esac
if [[ $createdir ]]; then
if [[ -n ${createdir} ]]; then
disp I "Archive extracted successfully in subdirectory."
elif [[ $nodir ]]; then
mv "./$dir/"* ./ && rmdir "$dir"
elif [[ -n ${nodir} ]]; then
mv "./${dir}/"* ./ && rmdir "${dir}"
disp I "Archive extracted successfully, no subdirectory needed."
else
subdirs=$(find $dir -maxdepth 1 | wc -l)
if [[ $subdirs -eq 2 ]]; then
mv ./$dir/* ./ && rmdir $dir
# Set nullglob to ensure the array is empty if no files match
shopt -s nullglob
local contents=( "${dir}"/* )
# Check if exactly one item exists and if that item is a directory
if [[ ${#contents[@]} -eq 1 ]] && [[ -d "${contents[0]}" ]]; then
# Single directory detected
mv "${contents[0]}"/* ./ && rmdir "${dir}"
disp I "Archive extracted successfully, no subdirectory needed."
else
disp I "Archive extracted successfully in subdirectory."
fi
shopt -u nullglob
fi
done
done

View File

@@ -336,6 +336,7 @@ file_stats()
}
}'
}
export -f file_stats
# ------------------------------------------------------------------------------

View File

@@ -49,6 +49,8 @@ ku Kill process owned by users in parameter
mcd Create a directory and go inside
meteo Display curent weather forecast for the configured city
ppg Display process matching the given parameter
ppn Display process matching the exact process name given in parameter
ppu Display processes owned by the given user
rain Let the rain fall
rmhost Remove host (IP and/or DNS name) for current known_host
rmspc Remove spaces from all the files in working directory

View File

@@ -73,9 +73,9 @@ showinfo()
local figopt="-f ansi_shadow"
fi
if [[ -n $figopt ]]; then
figlet -k "$figopt" "$(hostname)"
figlet -k $figopt $(hostname)
else
figlet "$(hostname)"
figlet $(hostname)
fi
else
hostname -f
@@ -83,6 +83,8 @@ showinfo()
echo ""
if command -v neofetch >/dev/null 2>&1; then
neofetch
elif command -v fastfetch >/dev/null 2>&1; then
fastfetch
else
(
if [[ -s /etc/os-release ]]; then

View File

@@ -43,6 +43,39 @@ ppg()
}
export -f ppg
# ------------------------------------------------------------------------------
# List processes owned by a specific user
# ------------------------------------------------------------------------------
ppu()
{
if [[ -z "$1" ]]; then
disp E "Usage: ppu <username>"
return 1
fi
# -u lists processes for a specific user
# -o provides a clean, standard output format
ps -u "$1" -o pid,user,%cpu,%mem,start,time,command
}
export -f ppu
# ------------------------------------------------------------------------------
# List processes by exact command name (no path/parameters)
# ------------------------------------------------------------------------------
ppn()
{
if [[ -z "$1" ]]; then
disp E "Usage: ppn <command_name>"
return 1
fi
# -e: select all processes
# -o: specify custom output columns (PID and Command name)
# grep -w: ensures exact word matching so 'bash' doesn't match 'dbash'
ps -eo pid,comm | grep -w "$1"
}
export -f ppn
# ------------------------------------------------------------------------------
# Get PID list of the given process name
# ------------------------------------------------------------------------------
@@ -63,7 +96,7 @@ gpid()
export -f gpid
# ------------------------------------------------------------------------------
# Kill all processes owned by the given users
# Kill all processes owned by the given users (kill user)
# ------------------------------------------------------------------------------
ku()
{
@@ -74,7 +107,7 @@ ku()
export -f ku
# ------------------------------------------------------------------------------
# Kill all children of a process then the process
# Kill all children of a process then the process (kill tree)
# ------------------------------------------------------------------------------
kt()
{

View File

@@ -39,19 +39,84 @@
# ------------------------------------------------------------------------------
rain()
{
show_usage() {
echo -e "Usage: rain [OPTIONS]"
echo -e ""
echo -e "Options:"
echo -e " -s, --speed NUM Set the drop delay in seconds (default: 0.050)."
echo -e " Lower values = faster rain."
echo -e " -c, --color COLOR Set the color theme (default: white)."
echo -e " -h, --help Display this help message and exit."
echo -e ""
echo -e "Available Colors:"
echo -e " \e[32mgreen\e[0m : The classic Matrix digital rain"
echo -e " \e[34mblue\e[0m : Deep ocean blue gradients"
echo -e " \e[31mred\e[0m : Crimson/Blood rain"
echo -e " \e[33myellow\e[0m : Amber and gold tones"
echo -e " \e[36mcyan\e[0m : Electric cyan/turquoise"
echo -e " white : Greyscale and white (original style)"
echo -e ""
echo -e "Example: rain --color green --speed 0.03"
}
local step_duration=0.050
local base_color="white" # default color scheme, can be overridden by --color
# Analyse arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
-s|--speed)
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
step_duration="$2"; shift
else
echo -e "\e[31mError: --speed requires a numeric value.\e[0m"
show_usage && return 1
fi
;;
-c|--color)
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
base_color="$2"; shift
else
echo -e "\e[31mError: --color requires a color name.\e[0m"
show_usage && return 1
fi
;;
-h|--help)
show_usage && return 0
;;
*)
echo -e "\e[31mUnknown option: $1\e[0m"
show_usage && return 1
;;
esac
shift
done
# Define colors (256-colors gradients)
local rain_colors=()
case $base_color in
green) # Matrix style green
for i in {22..28} {34..40} {46..48}; do rain_colors+=("\e[38;5;${i}m"); done ;;
blue) # Deep ocean blues
for i in {17..21} {27..33} {39..45}; do rain_colors+=("\e[38;5;${i}m"); done ;;
red) # Crimson / blood red
for i in {52..52} {88..88} {124..124} {160..160} {196..201}; do rain_colors+=("\e[38;5;${i}m"); done ;;
yellow) # Amber / gold
for i in {58..58} {100..100} {142..142} {184..184} {226..229}; do rain_colors+=("\e[38;5;${i}m"); done ;;
cyan) # Electric cyan / turquoise
for i in {30..31} {37..38} {44..45} {50..51}; do rain_colors+=("\e[38;5;${i}m"); done ;;
*) # Greyscale / white (original style)
rain_colors=("\e[37m" "\e[37;1m")
for i in {244..255}; do rain_colors+=("\e[38;5;${i}m"); done ;;
esac
local exit_st=0
local rain_cars=("|" "│" "┃" "┆" "┇" "┊" "┋" "╽" "╿")
local rain_colors=("\e[37m" "\e[37;1m")
# More from 256 color mode
for i in {244..255}; do
rain_colors=("${rain_colors[@]}" "\e[38;5;${i}m")
done
local rain_tab=${#rain_cars[@]}
local rain_color_tab=${#rain_colors[@]}
local num_rain_metadata=5
local term_height=$(tput lines)
local term_width=$(tput cols)
local step_duration=0.050
local X=0 Y=0 drop_length=0 rain_drop=0
local max_rain_width=0 new_rain_odd=0 falling_odd=0

View File

@@ -47,7 +47,7 @@ check_updates()
# Quiet mode is mostly used internally when profile_upgrade is called
quiet=1
fi
disp I "Checking for updates..."
[[ -n $quiet ]] && disp I "Checking for updates..."
local vfile="/tmp/version"
wget "$UPDT_URL/version" -O $vfile >/dev/null 2>&1 || {
disp E "Can't download version file, impossible to proceed!"
@@ -61,7 +61,7 @@ check_updates()
[[ $quiet ]] && disp I "You should upgrade to last version when possible."
result=1
else
disp I "Your version is up-to-date."
[[ -n $quiet ]] && disp I "Your version is up-to-date."
result=0
fi
rm -f $vfile
@@ -77,12 +77,10 @@ check_updates()
# ------------------------------------------------------------------------------
profile_upgrade()
{
check_updates -q
local need_update=$?
[[ $need_update -ne 1 ]] && {
if check_updates -q; then
disp "No update available."
return 0
}
fi
if [[ -s $MYPATH/profile.sh ]]; then
disp E "Installation path detection failed, cannot upgrade automatically."

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Begin profile
# ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
@@ -147,7 +147,7 @@ done
# Interactive shell detection, two methods available each one of those might have different result
# depending on distribution
#shopt -q login_shell && INTERACTIVE=1
[[ $- == *i* ]] && INTERACTIVE=1
[[ $- == *i* ]] && export INTERACTIVE=1
if [[ $INTERACTIVE ]]; then
# For compiling (as we often compile with LFS/0linux...)
@@ -184,6 +184,7 @@ if [[ $INTERACTIVE ]]; then
# Set default language
setfr
showinfo
check_updates -q
disp I "Profile version $PROFVERSION chargé..."
fi

View File

@@ -1 +1 @@
3.4.0
3.6.1