This commit is contained in:
pika 2025-05-18 12:56:45 +02:00
parent ba44f7d655
commit 53508118a2

39
yazi.sh
View file

@ -1,19 +1,35 @@
{ {
#!/usr/bin/env bash #!/usr/bin/env bash
PACKAGE=yazi
# ─< Check if the given command exists silently >───────────────────────────────────────── # ─< Check if the given command exists silently >─────────────────────────────────────────
command_exists() { command_exists() {
command -v "$@" >/dev/null 2>&1 command -v "$@" >/dev/null 2>&1
} }
if command_exists $PACKAGE; then # ─< package variable >───────────────────────────────────────────────────────────────────
echo_error "$PACKAGE is already installed!" unset PACKAGE
echo_error "Exiting now!"
return 69 # ─< argument list variables >────────────────────────────────────────────────────────────
unset silent
sleep 0.1
PACKAGE=yazi
if command_exists "$PACKAGE"; then
echo_warning "$PACKAGE is already installed!"
echo_warning "Exiting now!"
exit 69
fi fi
# ─< parse arguments and get variable contents >──────────────────────────────────────────
for arg in "$@"; do
case "$arg" in
--silent | -s)
silent=true
;;
esac
done
# WHY: # WHY:
# This import will give you the following variables: # This import will give you the following variables:
# _sudo="sudo -E" <- only if non root user # _sudo="sudo -E" <- only if non root user
@ -98,6 +114,10 @@
} }
main() { main() {
if $silent; then
echo_warning "Executing script silently!"
fi
if $arch; then if $arch; then
_install yazi _install yazi
elif ! $opensuse; then elif ! $opensuse; then
@ -108,13 +128,6 @@
} }
if getImports; then if getImports; then
case "$@" in
--silent | -s)
silent=true
echo_warning "Executing script silently.."
;;
*) silent=false ;;
esac
main main
fi fi
} }