{ #!/usr/bin/env bash # ─< Check if the given command exists silently >───────────────────────────────────────── command_exists() { command -v "$@" >/dev/null 2>&1 } # ─< package variable >─────────────────────────────────────────────────────────────────── unset PACKAGE # ─< 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 # ─< parse arguments and get variable contents >────────────────────────────────────────── for arg in "$@"; do case "$arg" in --silent | -s) silent=true ;; esac done # WHY: # This import will give you the following variables: # _sudo="sudo -E" <- only if non root user # distro = # 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" sleep 0.3 rm "$import" } # if command_exists curl; then # eval "$(curl -fsSL https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh)" # else # echo "curl is required, but missing.." # exit 1 # fi checkDependencies() { local deps=( ffmpeg 7zip poppler ) } evalCargo() { if [ -e "$HOME/.cargo/env" ]; then echo_note "Using $HOME/.cargo/env.." . "$HOME/.cargo/env" fi } i_yazi() { # if ! command_exists make || ! command_exists gcc; then # echo_error "The script might run into issues, because of make and gcc not being installed. Please install it, and run the script again, if it fails!" # fi evalCargo if command_exists cargo; then echo_info "Installing yazi through cargo" elif command_exists curl; then echo_note "no cargo found, using curl to install rustup" curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh evalCargo rustup update echo_info "Installing yazi through cargo" else echo_warning "neither cargo, nor curl were found. Cannot continue!" fi cargo install --locked yazi-fm yazi-cli c_yazi } c_yazi() { if [ -e "$HOME/.config/yazi/package.toml" ]; then if command_exists ya; then ya pack -i fi else echo_warning "There was no yazi config found.. " fi } main() { if $silent; then echo_warning "Executing script silently!" fi if $arch; then _install yazi elif ! $opensuse; then i_yazi else echo_warning "$distro is not compatible with this script" fi } if getImports; then main fi }