This commit is contained in:
pika 2025-05-24 15:48:51 +02:00
parent b7251bc8c4
commit 4c9f811ba7

114
yazi.sh
View file

@ -6,35 +6,37 @@
command -v "$@" >/dev/null 2>&1 command -v "$@" >/dev/null 2>&1
} }
# WHY: source-script() {
# This import will give you the following variables: local url="$1"
# _sudo="sudo -E" <- only if non root user local import="$(mktemp)"
# distro = <distro name, like 'arch', 'debian', 'fedora'..>
# arch = bool
# fedora = bool
# opensuse = bool....
# You can then use it for, `if $arch; then`
# Also this gives you the _install command, which installs a package pased on the packagemanager/distro used.
# CAUTION:
# This only wokrs for generic package names, like neovim, or vim, or tmux etc..
# not every package packagemanager has the same packagenames for their packages..
getImports() {
i="https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh"
import="$(mktemp)"
if command_exists curl; then
curl -fsSL $i -o $import
else
echo "curl is required, but missing.."
exit 1
fi
source "$import" # ─< if $1 is a local file, source this one instead >─────────────────────────────────────
sleep 0.3 if [ -f "$url" ]; then
rm "$import" source "$url"
sleep 0.1
return 0
else
# ─< if $1 is a url, grab it and source it, also deletes afterwards >─────────────────────
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
source "$import"
echo "${BLUE}Sourcing external script:${NC} $url"
line
sleep 0.1
rm -f "$import"
fi
} }
getDependencies() { getDependencies() {
echo_info "Checking build dependencies.." pen bold blue "Checking build dependencies.."
# INFO: # INFO:
# ╭─────────────────────────────────────────────────────────────────────────╮ # ╭─────────────────────────────────────────────────────────────────────────╮
@ -71,11 +73,11 @@
case "$distro" in case "$distro" in
debian | ubuntu | arch | fedora | alpine | opensuse) debian | ubuntu | arch | fedora | alpine | opensuse)
checkAndInstall "${generalDeps[@]}" check-and-install "${generalDeps[@]}"
checkAndInstall "${pkgArray[@]}" check-and-install "${pkgArray[@]}"
;; ;;
*) *)
echo_error "There are no dependencies to install for $distro" echo-error "There are no dependencies to install for $distro"
return 69 return 69
;; ;;
esac esac
@ -83,7 +85,7 @@
evalCargo() { evalCargo() {
if [ -e "$HOME/.cargo/env" ]; then if [ -e "$HOME/.cargo/env" ]; then
echo_note "Using $HOME/.cargo/env.." pen bold blue "Using $HOME/.cargo/env.."
. "$HOME/.cargo/env" . "$HOME/.cargo/env"
fi fi
} }
@ -98,11 +100,12 @@
evalCargo evalCargo
run rustup update spin bold grey "Updating rustsources.."
run rustup update && chech "Updated sources" || throw-err
echo_info "Installing yazi through cargo" pen bold blue "Installing yazi through cargo"
else else
echo_warning "neither cargo, nor curl were found. Cannot continue!" pen bold red "neither cargo, nor curl were found. Cannot continue!"
return 69 return 69
fi fi
@ -110,37 +113,37 @@
} }
yazi_setup() { yazi_setup() {
run ya pack -u || run ya pack -i ya pack -u || ya pack -i
} }
c_yazi() { c_yazi() {
if [ -e "$HOME/.config/yazi/package.toml" ]; then if [ -e "$HOME/.config/yazi/package.toml" ]; then
if command_exists ya; then if command_exists ya; then
yazi_setup || echo_error "Yazi was not setup properly.." yazi_setup || echo-error "Yazi was not setup properly.."
else else
if [ -e "$HOME/.cargo/env" ]; then if [ -e "$HOME/.cargo/env" ]; then
echo_info "Loadet $HOME/.cargo/env" pen bold blue "Loadet $HOME/.cargo/env"
. "$HOME/.cargo/env" . "$HOME/.cargo/env"
yazi_setup || echo_error "Yazi was not setup properly.." yazi_setup || echo-error "Yazi was not setup properly.."
else else
echo_error "Something went wrong when installing yazi.. ya is not available.." echo-error "Something went wrong when installing yazi.. ya is not available.."
fi fi
fi fi
else else
echo_warning "There was no yazi config found.. " pen bold yellow "There was no yazi config found.. "
fi fi
} }
main() { main() {
if $silent; then if $silent; then
echo_warning "Executing script silently!" pen bold yellow "Executing script silently!"
fi fi
case "$distro" in case "$distro" in
arch) arch)
run _install yazi pkg-install yazi
;; ;;
debian | ubuntu | fedora) debian | ubuntu | fedora)
if getDependencies; then if getDependencies; then
@ -149,12 +152,35 @@
fi fi
;; ;;
*) *)
echo_warning "$distro is not compatible with this script" pen bold yellow "$distro is not compatible with this script"
;; ;;
esac esac
} }
if getImports; then # WHY:
# This import will give you the following variables:
# _sudo="sudo -E" <- only if non root user
# distro = <distro name, like 'arch', 'debian', 'fedora'..>
# arch = bool
# fedora = bool
# opensuse = bool....
# You can then use it for, `if $arch; then`
# Also this gives you the pkg-install command, which installs a package pased on the packagemanager/distro used.
# CAUTION:
# This only wokrs for generic package names, like neovim, or vim, or tmux etc..
# not every package packagemanager has the same packagenames for their packages..
setup-env() {
# local beddu=https://git.k4li.de/scripts/beddu/raw/branch/main/dist/beddu.sh
# local pika=https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh
local dream=https://git.k4li.de/scripts/imports/raw/branch/main/dream.sh
if ! command_exists pkg-install && ! command_exists check-and-install && ! command_exists spin; then
source-script $dream
line
fi
}
if setup-env; then
# ─< package variable >─────────────────────────────────────────────────────────────────── # ─< package variable >───────────────────────────────────────────────────────────────────
unset PACKAGE unset PACKAGE
@ -165,8 +191,8 @@
PACKAGE=yazi PACKAGE=yazi
if command_exists "$PACKAGE"; then if command_exists "$PACKAGE"; then
echo_warning "$PACKAGE is already installed!" pen bold yellow "$PACKAGE is already installed!"
echo_warning "Exiting now!" pen bold yellow "Exiting now!"
exit 69 exit 69
fi fi