Compare commits
7 Commits
9b2c764181
...
v3.6.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
128cfe8c87 | ||
|
|
e1c2705fdd | ||
|
|
368bc11acf | ||
|
|
a068d57ba5 | ||
|
|
ffee8c2e47 | ||
|
|
9ff5792790 | ||
|
|
6a2d9b0fee |
@@ -7,6 +7,14 @@ Current version from Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||
------------------------------------------------------------------------------
|
||||
Version history:
|
||||
------------------------------------------------------------------------------
|
||||
# 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
|
||||
|
||||
@@ -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,137 @@ 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="."
|
||||
[[ -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 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." && \
|
||||
continue
|
||||
# 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
|
||||
}
|
||||
|
||||
for f in "$zitem"/*.zip; do
|
||||
disp I "Processing archive $f... "
|
||||
local dir=${f::-4}
|
||||
|
||||
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
|
||||
|
||||
@@ -336,6 +336,7 @@ file_stats()
|
||||
}
|
||||
}'
|
||||
}
|
||||
export -f file_stats
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user