diff --git a/yazi.sh b/yazi.sh index 98e9a9a..9b70e83 100644 --- a/yazi.sh +++ b/yazi.sh @@ -6,35 +6,37 @@ command -v "$@" >/dev/null 2>&1 } - # 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-script() { + local url="$1" + local import="$(mktemp)" - source "$import" - sleep 0.3 - rm "$import" + # ─< if $1 is a local file, source this one instead >───────────────────────────────────── + if [ -f "$url" ]; then + 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() { - echo_info "Checking build dependencies.." + pen bold blue "Checking build dependencies.." # INFO: # ╭─────────────────────────────────────────────────────────────────────────╮ @@ -71,11 +73,11 @@ case "$distro" in debian | ubuntu | arch | fedora | alpine | opensuse) - checkAndInstall "${generalDeps[@]}" - checkAndInstall "${pkgArray[@]}" + check-and-install "${generalDeps[@]}" + 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 ;; esac @@ -83,7 +85,7 @@ evalCargo() { if [ -e "$HOME/.cargo/env" ]; then - echo_note "Using $HOME/.cargo/env.." + pen bold blue "Using $HOME/.cargo/env.." . "$HOME/.cargo/env" fi } @@ -98,11 +100,12 @@ 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 - echo_warning "neither cargo, nor curl were found. Cannot continue!" + pen bold red "neither cargo, nor curl were found. Cannot continue!" return 69 fi @@ -110,37 +113,37 @@ } yazi_setup() { - run ya pack -u || run ya pack -i + ya pack -u || ya pack -i } c_yazi() { if [ -e "$HOME/.config/yazi/package.toml" ]; 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 if [ -e "$HOME/.cargo/env" ]; then - echo_info "Loadet $HOME/.cargo/env" + pen bold blue "Loadet $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 - 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 else - echo_warning "There was no yazi config found.. " + pen bold yellow "There was no yazi config found.. " fi } main() { if $silent; then - echo_warning "Executing script silently!" + pen bold yellow "Executing script silently!" fi case "$distro" in arch) - run _install yazi + pkg-install yazi ;; debian | ubuntu | fedora) if getDependencies; then @@ -149,12 +152,35 @@ fi ;; *) - echo_warning "$distro is not compatible with this script" + pen bold yellow "$distro is not compatible with this script" ;; esac } - if getImports; then + # 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 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 >─────────────────────────────────────────────────────────────────── unset PACKAGE @@ -165,8 +191,8 @@ PACKAGE=yazi 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