This commit is contained in:
pika 2025-05-24 00:42:56 +02:00
parent 25b012ac4d
commit ec2d014f9d

View file

@ -6,18 +6,6 @@
command -v "$@" >/dev/null 2>&1
}
# 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..
source-script() {
local url="$1"
local import="$(mktemp)"
@ -39,7 +27,8 @@
fi
source "$import"
echo_info "Sourcing external script:${NC} $url"
echo "${BLUE}Sourcing external script:${NC} $url"
sleep 0.1
rm -f "$import"
fi
@ -67,27 +56,10 @@
case "$distro" in
debian | ubuntu | arch | fedora | alpine | opensuse)
for pkg in "${pkgArray[@]}"; do
if ! command_exists $pkg; then
spin bold "$(pen bold yellow Installing) $pkg"
if run --err err pkg-install $pkg; then
check "$(pen bold green Installed) $pkg"
else
throw "Something went wrong! Could not install $(pen bold red $pkg)"
echo_error "${err:-}"
fi
# minifyed
# run --err err pkg-install $pkg && check "$(pen bold green Installed) $pkg" ||
# throw "Something went wrong! Could not install $(pen bold red $pkg)" &&
# echo_error "${err:-}"
else
check "$pkg $(pen grey already installed)"
fi
done
check-and-install ${pkgArray[@]}
;;
*)
echo_error "Cannot install for $distro"
echo-error "Cannot install for $distro"
exit 69
;;
esac
@ -113,7 +85,7 @@
# minifyed version..
# run --err err git clone --depth=1 https://github.com/neovim/neovim.git && check green "Cloned $PACKAGE sources" && cd neovim || throw "Error cloning neovim" && pen bold red "The error: ${err:-}"
else
echo_error "Git was required, but is missing.. exiting now"
echo-error "Git was required, but is missing.. exiting now"
return 69
fi
@ -132,10 +104,10 @@
check "$PACKAGE installed!"
else
thorw "Installation of $PACKAGE has failed!"
echo_error "${err:-}"
echo-error "${err:-}"
fi
else
echo_error "${err:-}"
echo-error "${err:-}"
exit 69
fi
}
@ -150,10 +122,10 @@
check "Prefetched config"
else
throw "Prefetching config went terribly wrong!"
echo_error "${err:-}"
echo-error "${err:-}"
fi
else
# echo_warning "You don't have a neovim config installed. Do you want to clone one now? [Y]es (standard), [m]inimal, [n]o"
# pen bold yellow "You don't have a neovim config installed. Do you want to clone one now? [Y]es (standard), [m]inimal, [n]o"
# read -r askNvim
choose askNvim "You don't have a neovim config installed. Do you want to clone one now?" "pika's standard config" "pika's minimal config" own none </dev/tty
@ -201,7 +173,7 @@
fi
;;
*)
echo_error "Something failed HARD!"
echo-error "Something failed HARD!"
exit 69
;;
esac
@ -220,11 +192,11 @@
main() {
if $silent; then
echo_warning "Executing script silently!"
pen bold yellow "Executing script silently!"
fi
if ! getDependencies; then
echo_error "Error when installing dependencies.."
echo-error "Error when installing dependencies.."
fi
cloneSources
@ -233,16 +205,25 @@
checkAndInitConfig </dev/tty
}
# 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 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 checkAndInstall; then
source-script $pika
fi
if ! command_exists pen && ! command_exists spin; then
source-script $beddu
if ! command_exists pkg-install && ! command_exists check-and-install && ! command_exists spin; then
source-script $dream
fi
}
@ -257,8 +238,8 @@
PACKAGE=neovim
if command_exists "$PACKAGE"; then
echo_warning "$PACKAGE is already installed!"
echo_warning "Exiting now!"
pen bold yellow "$PACKAGE is already installed!"
pen bold yellow "Exiting now!"
exit 69
fi