test.sh
This commit is contained in:
parent
5fd2040977
commit
04867a7def
2 changed files with 159 additions and 2 deletions
157
test.sh
Executable file
157
test.sh
Executable file
|
@ -0,0 +1,157 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||||
|
command_exists() {
|
||||||
|
command -v "$@" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
getImports() {
|
||||||
|
local url="https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh"
|
||||||
|
local import="$(mktemp)"
|
||||||
|
if command_exists curl; then
|
||||||
|
curl -fsSL $url -o $import
|
||||||
|
elif command_exists wget; then
|
||||||
|
wget -o $import $url
|
||||||
|
else
|
||||||
|
echo "curl/wget is required, but missing.."
|
||||||
|
exit 69
|
||||||
|
fi
|
||||||
|
|
||||||
|
. "$import"
|
||||||
|
sleep 0.1
|
||||||
|
rm -f "$import"
|
||||||
|
}
|
||||||
|
|
||||||
|
getDependencies() {
|
||||||
|
echo_info "Checking build dependencies.."
|
||||||
|
|
||||||
|
# INFO:
|
||||||
|
# ╭─────────────────────────────────────────────────────────────────────────╮
|
||||||
|
# │ You can define dependencies for various linux distros here. It will │
|
||||||
|
# │ automagically be pulled via the $pkgArray[$distro] variable │
|
||||||
|
# ╰─────────────────────────────────────────────────────────────────────────╯
|
||||||
|
depsDebian=()
|
||||||
|
depsFedora=()
|
||||||
|
depsOpensuse=()
|
||||||
|
depsArch=()
|
||||||
|
depsAlpine=()
|
||||||
|
|
||||||
|
declare -A deps=(
|
||||||
|
[debian]="depsDebian"
|
||||||
|
[ubuntu]="depsUbuntu"
|
||||||
|
[fedora]="depsFedora"
|
||||||
|
[arch]="depsArch"
|
||||||
|
[alpine]="depsAlpine"
|
||||||
|
[opensuse]="depsOpensuse"
|
||||||
|
)
|
||||||
|
|
||||||
|
# INFO:
|
||||||
|
# ╭────────────────────────────────────────────────────────────────╮
|
||||||
|
# │ This variable stores the packages you provided for each distro │
|
||||||
|
# ╰────────────────────────────────────────────────────────────────╯
|
||||||
|
declare -n pkgArray="${deps[$distro]}"
|
||||||
|
|
||||||
|
case "$distro" in
|
||||||
|
debian | ubuntu | arch | fedora | alpine | opensuse)
|
||||||
|
checkAndInstall "${pkgArray[@]}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo_error "There are no dependencies to install for $distro"
|
||||||
|
return 69
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# echo default
|
||||||
|
|
||||||
|
main() {
|
||||||
|
if $silent; then
|
||||||
|
pen bold red "Executing script silently!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Kindly ask for input (empty answer is accepted)
|
||||||
|
seek name "What's your name?"
|
||||||
|
pen "Hello, $name!"
|
||||||
|
|
||||||
|
# Firmly ask for input (empty answer NOT accepted)
|
||||||
|
# request name "No really, what's your name?"
|
||||||
|
# pen "There you go, $name!"
|
||||||
|
|
||||||
|
# Yes/no confirmation (defaults to "yes")
|
||||||
|
if confirm "Continue?"; then
|
||||||
|
spin "Working on it.."
|
||||||
|
sleep 2
|
||||||
|
check "Done!"
|
||||||
|
pen green "Continuing..."
|
||||||
|
else
|
||||||
|
spin "Working on it.."
|
||||||
|
sleep 2
|
||||||
|
check "Done!"
|
||||||
|
pen red "waiting.."
|
||||||
|
sleep 2
|
||||||
|
repen spin "Almost done.."
|
||||||
|
sleep 2
|
||||||
|
repen spin "Waiting some more.."
|
||||||
|
sleep 2
|
||||||
|
check "Task completed!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Defaulting to "no"
|
||||||
|
if confirm --default-no "Are you sure?"; then
|
||||||
|
pen green "Proceeding..."
|
||||||
|
else
|
||||||
|
pen red "Cancelled."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Menu selection
|
||||||
|
choose color "Select a color:" "Red" "Green" "Blue"
|
||||||
|
pen "You selected: $color"
|
||||||
|
|
||||||
|
# source_script "https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh"
|
||||||
|
|
||||||
|
# case "$distro" in
|
||||||
|
# arch)
|
||||||
|
# pen bold blue "This is Arch!"
|
||||||
|
# ;;
|
||||||
|
# debian)
|
||||||
|
# pen bold red "This is Debian!"
|
||||||
|
# ;;
|
||||||
|
# ubuntu)
|
||||||
|
# pen bold orange "This is Ubuntu!"
|
||||||
|
# ;;
|
||||||
|
# fedora)
|
||||||
|
# pen blue "This is Fedora!"
|
||||||
|
# ;;
|
||||||
|
# alpine)
|
||||||
|
# pen italic blue "This is Alpine!"
|
||||||
|
# ;;
|
||||||
|
# opensuse)
|
||||||
|
# pen green bold "This is OpenSuse!"
|
||||||
|
# ;;
|
||||||
|
# *)
|
||||||
|
# echo "$distro is not supported by this script!"
|
||||||
|
# exit 1
|
||||||
|
# ;;
|
||||||
|
# esac
|
||||||
|
}
|
||||||
|
|
||||||
|
if getImports; then
|
||||||
|
# ─< package variable >───────────────────────────────────────────────────────────────────
|
||||||
|
unset PACKAGE
|
||||||
|
|
||||||
|
# ─< argument list variables >────────────────────────────────────────────────────────────
|
||||||
|
silent=false
|
||||||
|
|
||||||
|
sleep 0.1
|
||||||
|
|
||||||
|
# ─< parse arguments and get variable contents >──────────────────────────────────────────
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--silent | -s)
|
||||||
|
export silent=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
main
|
||||||
|
fi
|
4
yazi.sh
4
yazi.sh
|
@ -91,9 +91,9 @@
|
||||||
i_yazi() {
|
i_yazi() {
|
||||||
evalCargo
|
evalCargo
|
||||||
if command_exists cargo; then
|
if command_exists cargo; then
|
||||||
echo_info "Installing yazi through cargo"
|
echo_pkg install "Installing yazi through cargo"
|
||||||
elif command_exists curl; then
|
elif command_exists curl; then
|
||||||
echo_note "no cargo found, using curl to install rustup"
|
echo_pkg deps "no cargo found, using curl to install rustup"
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||||
|
|
||||||
evalCargo
|
evalCargo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue