diff --git a/sh.json b/sh.json index c5f29dd..28f64f5 100644 --- a/sh.json +++ b/sh.json @@ -1 +1 @@ -{"command_exists":{"prefix":"command_exists","body":["# ─< Check if the given command exists silently >─────────────────────────────────────────","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}"]},"posix logging essentials + logging":{"prefix":["posix logging essentials","logging"],"body":["# ─< ANSI color codes >───────────────────────────────────────────────────────────────────","RED='\\033[0;31m'","CYAN='\\033[0;36m'","YELLOW='\\033[0;33m'","LIGHT_GREEN='\\033[0;92m'","BOLD='\\033[1m'","NC='\\033[0m'","","# ─< Initialize storage variables >───────────────────────────────────────────────────────","_STORED_ERRORS=\"\"","_STORED_WARNINGS=\"\"","_STORED_INFOS=\"\"","_STORED_NOTES=\"\"","","# ─< echo functions that store and display messages >────────────────────────────","echo_error() {"," local message=\"\\${RED}\\$1\\${NC}\\n\""," printf \"\\$message\" >&2"," _STORED_ERRORS=\"\\${_STORED_ERRORS}\\${message}\"","}","","echo_warning() {"," local message=\"\\${YELLOW}\\$1\\${NC}\\n\""," printf \"\\$message\""," _STORED_WARNINGS=\"\\${_STORED_WARNINGS}\\${message}\"","}","","echo_info() {"," local message=\"\\${CYAN}\\$1\\${NC}\\n\""," printf \"\\$message\""," _STORED_INFOS=\"\\${_STORED_INFOS}\\${message}\"","}","","echo_note() {"," local message=\"\\${LIGHT_GREEN}\\$1\\${NC}\\n\""," printf \"\\$message\""," _STORED_NOTES=\"\\${_STORED_NOTES}\\${message}\"","}","","# ─< Improved display function that only shows categories with content >──────────────────","display_stored_messages() {"," local has_messages=0",""," # ─< First check if we have any messages at all >─────────────────────────────────────────"," if [ -z \"\\$_STORED_ERRORS\" ] && [ -z \"\\$_STORED_WARNINGS\" ] && [ -z \"\\$_STORED_INFOS\" ] && [ -z \"\\$_STORED_NOTES\" ]; then"," return 0"," fi",""," # ─< Now display each non-empty category with proper spacing >────────────────────────────"," if [ -n \"\\$_STORED_ERRORS\" ]; then"," printf \"\\n\\${BOLD}\\${RED}=== Errors ===\\${NC}\\n\""," printf \"\\$_STORED_ERRORS\""," has_messages=1"," fi",""," if [ -n \"\\$_STORED_WARNINGS\" ]; then"," [ \"\\$has_messages\" -eq 1 ] && printf \"\\n\""," printf \"\\${BOLD}\\${YELLOW}=== Warnings ===\\${NC}\\n\""," printf \"\\$_STORED_WARNINGS\""," has_messages=1"," fi",""," if [ -n \"\\$_STORED_INFOS\" ]; then"," [ \"\\$has_messages\" -eq 1 ] && printf \"\\n\""," printf \"\\${BOLD}\\${CYAN}=== Info ===\\${NC}\\n\""," printf \"\\$_STORED_INFOS\""," has_messages=1"," fi",""," if [ -n \"\\$_STORED_NOTES\" ]; then"," [ \"\\$has_messages\" -eq 1 ] && printf \"\\n\""," printf \"\\${BOLD}\\${LIGHT_GREEN}=== Notes ===\\${NC}\\n\""," printf \"\\$_STORED_NOTES\""," fi","}"]},"posix packager detection + get_packager":{"prefix":["posix packager detection","get_packager"],"body":["# ─< Distribution detection and installation >────────────────────────────────────────","get_packager() {"," if [ -e /etc/os-release ]; then"," echo_info \"Detecting distribution...\""," . /etc/os-release",""," # ─< Convert \\$ID and \\$ID_LIKE to lowercase >──────────────────────────────────────────────"," ID=\\$(printf \"%s\" \"\\$ID\" | tr '[:upper:]' '[:lower:]')"," ID_LIKE=\\$(printf \"%s\" \"\\$ID_LIKE\" | tr '[:upper:]' '[:lower:]')",""," case \"\\$ID\" in"," ubuntu | pop) ${1:inst_ubuntu} ;;"," debian) ${2:inst_debian} ;;"," fedora) ${3:inst_fedora} ;;"," alpine) inst_alpine ;;"," arch | manjaro | garuda | endeavour) ${4:inst_arch} ;;"," opensuse*) inst_opensuse ;;"," *)"," if [ \"\\${ID_LIKE#*debian}\" != \"\\$ID_LIKE\" ]; then"," ${2:inst_debian}"," elif [ \"\\${ID_LIKE#*ubuntu}\" != \"\\$ID_LIKE\" ]; then"," ${1:inst_ubuntu}"," elif [ \"\\${ID_LIKE#*arch}\" != \"\\$ID_LIKE\" ]; then"," ${4:inst_arch}"," elif [ \"\\${ID_LIKE#*fedora}\" != \"\\$ID_LIKE\" ]; then"," ${3:inst_fedora}"," elif [ \"\\${ID_LIKE#*suse}\" != \"\\$ID_LIKE\" ]; then"," inst_opensuse"," else"," echo_error \"Unsupported distribution: \\$ID\""," exit 1"," fi"," ;;"," esac"," else"," echo_error \"Unable to detect distribution. /etc/os-release not found.\""," exit 1"," fi","}"]},"shstruct + shdefault":{"prefix":["shstruct","shdefault"],"body":["#!/bin/sh","","# ╭───────────────╮","# │ env functions │","# ╰───────────────╯","# ───────────────────────────────────< ANSI color codes >───────────────────────────────────","RED='\\033[0;31m'","CYAN='\\033[0;36m'","YELLOW='\\033[0;33m'","LIGHT_GREEN='\\033[0;92m'","BOLD='\\033[1m'","NC='\\033[0m' # No Color","","echo_error() {"," printf \"\\${BOLD}\\${RED}ERROR: \\${NC}\\${RED}%s\\${NC}\\n\" \"\\$1\" >&2","}","","echo_info() {"," printf \"\\${BOLD}\\${CYAN}INFO: \\${NC}\\${CYAN}%s\\${NC}\\n\" \"\\$1\"","}","","echo_warning() {"," printf \"\\${BOLD}\\${YELLOW}WARNING: \\${NC}\\${YELLOW}%s\\${NC}\\n\" \"\\$1\"","}","","echo_note() {"," printf \"\\${BOLD}\\${LIGHT_GREEN}NOTE: \\${NC}\\${LIGHT_GREEN}%s\\${NC}\\n\" \"\\$1\"","}","","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}","","# ─────────────< Check if the user is root and set sudo variable if necessary >─────────────","check_root() {"," if [ \"\\$(id -u)\" -ne 0 ]; then"," if command_exists sudo; then"," echo_info \"User is not root. Using sudo for privileged operations.\""," _sudo=\"sudo\""," else"," echo_error \"No sudo found and you're not root! Can't install packages.\""," return 1"," fi"," else"," echo_info \"Root access confirmed.\""," _sudo=\"\""," fi","}","","# ──────────────────────< Check if the given command exists silently >──────────────────────","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}","","# ╭────────────────────────────────────╮","# │ insert your scripts/functions here │","# ╰────────────────────────────────────╯","${1:Your script here}","# ───────────────────────────────< main function to execute >───────────────────────────────","main() {"," if check_root; then"," else"," echo_error \"Something went terribly wrong!\""," fi","}","","main"]},"docker build script + build script":{"prefix":["docker build script","build script"],"body":["#!/usr/bin/env bash","# ─< ANSI color codes >───────────────────────────────────────────────────────────────────","RED='\\033[0;31m'","CYAN='\\033[0;36m'","NC='\\033[0m' # No Color","","echo_error() {"," printf \"\\${BOLD}\\${RED}ERROR: \\${NC}\\${RED}%s\\${NC}\\n\" \"\\$1\" >&2","}","","echo_info() {"," printf \"\\${BOLD}\\${CYAN}INFO: \\${NC}\\${CYAN}%s\\${NC}\\n\" \"\\$1\"","}","","# ─< Check if the given command exists silently >─────────────────────────────────────────","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}","","image=\"${1:image}\"","tag=\"${2:latest}\"","","if command_exists docker; then"," if [ -e ./Dockerfile ]; then"," docker build -t \"\\${image}:\\${tag}\" ."," else"," echo_error \"There was no dockerfile present in this directory: \\$PWD\""," fi","else"," echo_error \"Docker is not installed!\"","fi"]},"posix echo essentials + echos":{"prefix":["posix echo essentials","echos"],"body":["# ─< ANSI color codes >───────────────────────────────────────────────────────────────────","RED='\\033[0;31m'","CYAN='\\033[0;36m'","YELLOW='\\033[0;33m'","LIGHT_GREEN='\\033[0;92m'","BOLD='\\033[1m'","NC='\\033[0m' # No Color","","echo_error() {"," printf \"\\${BOLD}\\${RED}ERROR: \\${NC}\\${RED}%s\\${NC}\\n\" \"\\$1\" >&2","}","","echo_info() {"," printf \"\\${BOLD}\\${CYAN}INFO: \\${NC}\\${CYAN}%s\\${NC}\\n\" \"\\$1\"","}","","echo_warning() {"," printf \"\\${BOLD}\\${YELLOW}WARNING: \\${NC}\\${YELLOW}%s\\${NC}\\n\" \"\\$1\"","}","","echo_note() {"," printf \"\\${BOLD}\\${LIGHT_GREEN}NOTE: \\${NC}\\${LIGHT_GREEN}%s\\${NC}\\n\" \"\\$1\"","}"]},"posix check_root + cr":{"prefix":["posix check_root","cr"],"body":["# ─< Check if the given command exists silently >─────────────────────────────────────────","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}","","# ─< Check if the user is root and set sudo variable if necessary >───────────────────────","check_root() {"," if [ \"\\$(id -u)\" -ne 0 ]; then"," if command_exists sudo; then"," echo_info \"User is not root. Using sudo for privileged operations.\""," _sudo=\"sudo -E\""," else"," echo_error \"No sudo found and you're not root! Can't install packages.\""," return 1"," fi"," else"," echo_info \"Root access confirmed.\""," _sudo=\"\""," fi","}"]},"linux pkg install + build script":{"prefix":["linux pkg install","build script"],"body":["{"," #!/usr/bin/env bash",""," # ─< Check if the given command exists silently >─────────────────────────────────────────"," command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1"," }",""," getImports() {"," local url=\"\\$1\""," local import=\"\\$(mktemp)\""," 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\""," sleep 0.1"," rm -f \"\\$import\""," }",""," setup-env() {"," # 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.."," #"," # 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"," # dream ~= combined beddu and pika"," 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 pen; then"," getImports \\$dream"," fi"," }",""," getDependencies() {"," # INFO:"," # ╭─────────────────────────────────────────────────────────────────────────╮"," # │ You can define dependencies for various linux distros here. It will │"," # │ automagically be pulled via the \\$pkgArray[\\$distro] variable │"," # ╰─────────────────────────────────────────────────────────────────────────╯"," depsDebian=()"," depsUbuntu=()"," depsFedora=()"," depsOpensuse=()"," depsArch=()"," depsAlpine=()",""," declare -A deps=("," [debian]=\"depsDebian\""," [ubuntu]=\"depsUbuntu\""," [fedora]=\"depsFedora\""," [arch]=\"depsArch\""," [alpine]=\"depsAlpine\""," [opensuse]=\"depsOpensuse\""," )",""," # INFO:"," # ╭────────────────────────────────────────────────────────────────╮"," # │ This variable stores the packages you provided for each distro │"," # ╰────────────────────────────────────────────────────────────────╯"," declare -n pkgArray=\"\\${deps[\\$distro]}\"",""," case \"\\$distro\" in"," debian | ubuntu | arch | fedora | alpine | opensuse)"," # installs packages inside the ${pkgArray[@]} list, which is the $distro part of the confiruation above"," check-and-install \\${pkgArray[@]}"," ;;"," *)"," pen bold yellow \"There are no dependencies to install for \\$distro\""," return 69"," ;;"," esac"," }","","${2:#your-script-logic}",""," main() {"," if \\$silent; then"," pen yellow \"ARG: Executing script silently!\""," fi",""," if ! getDependencies; then"," throw \"Error when installing dependencies..\""," fi",""," case \"\\$distro\" in"," arch)"," echo \"arch\""," ;;"," debian)"," echo \"debian\""," ;;"," ubuntu)"," echo \"ubuntu\""," ;;"," fedora)"," echo \"fedora\""," ;;"," alpine)"," echo \"alpine\""," ;;"," opensuse)"," echo \"opensuse\""," ;;"," *)"," echo \"\\$distro is not supported by this script!\""," exit 1"," ;;"," esac"," }",""," if getImports; then"," # ─< package variable >───────────────────────────────────────────────────────────────────"," unset PACKAGE",""," # ─< argument list variables >────────────────────────────────────────────────────────────"," silent=false",""," sleep 0.1",""," PACKAGE=packagename"," 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)"," export silent=true"," ;;"," esac"," done",""," main"," fi","}"]}} \ No newline at end of file +{"posix check_root + cr":{"prefix":["posix check_root","cr"],"body":["# ─< Check if the given command exists silently >─────────────────────────────────────────","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}","","# ─< Check if the user is root and set sudo variable if necessary >───────────────────────","check_root() {"," if [ \"\\$(id -u)\" -ne 0 ]; then"," if command_exists sudo; then"," echo_info \"User is not root. Using sudo for privileged operations.\""," _sudo=\"sudo -E\""," else"," echo_error \"No sudo found and you're not root! Can't install packages.\""," return 1"," fi"," else"," echo_info \"Root access confirmed.\""," _sudo=\"\""," fi","}"]},"posix echo essentials + echos":{"prefix":["posix echo essentials","echos"],"body":["# ─< ANSI color codes >───────────────────────────────────────────────────────────────────","RED='\\033[0;31m'","CYAN='\\033[0;36m'","YELLOW='\\033[0;33m'","LIGHT_GREEN='\\033[0;92m'","BOLD='\\033[1m'","NC='\\033[0m' # No Color","","echo_error() {"," printf \"\\${BOLD}\\${RED}ERROR: \\${NC}\\${RED}%s\\${NC}\\n\" \"\\$1\" >&2","}","","echo_info() {"," printf \"\\${BOLD}\\${CYAN}INFO: \\${NC}\\${CYAN}%s\\${NC}\\n\" \"\\$1\"","}","","echo_warning() {"," printf \"\\${BOLD}\\${YELLOW}WARNING: \\${NC}\\${YELLOW}%s\\${NC}\\n\" \"\\$1\"","}","","echo_note() {"," printf \"\\${BOLD}\\${LIGHT_GREEN}NOTE: \\${NC}\\${LIGHT_GREEN}%s\\${NC}\\n\" \"\\$1\"","}"]},"posix logging essentials + logging":{"prefix":["posix logging essentials","logging"],"body":["# ─< ANSI color codes >───────────────────────────────────────────────────────────────────","RED='\\033[0;31m'","CYAN='\\033[0;36m'","YELLOW='\\033[0;33m'","LIGHT_GREEN='\\033[0;92m'","BOLD='\\033[1m'","NC='\\033[0m'","","# ─< Initialize storage variables >───────────────────────────────────────────────────────","_STORED_ERRORS=\"\"","_STORED_WARNINGS=\"\"","_STORED_INFOS=\"\"","_STORED_NOTES=\"\"","","# ─< echo functions that store and display messages >────────────────────────────","echo_error() {"," local message=\"\\${RED}\\$1\\${NC}\\n\""," printf \"\\$message\" >&2"," _STORED_ERRORS=\"\\${_STORED_ERRORS}\\${message}\"","}","","echo_warning() {"," local message=\"\\${YELLOW}\\$1\\${NC}\\n\""," printf \"\\$message\""," _STORED_WARNINGS=\"\\${_STORED_WARNINGS}\\${message}\"","}","","echo_info() {"," local message=\"\\${CYAN}\\$1\\${NC}\\n\""," printf \"\\$message\""," _STORED_INFOS=\"\\${_STORED_INFOS}\\${message}\"","}","","echo_note() {"," local message=\"\\${LIGHT_GREEN}\\$1\\${NC}\\n\""," printf \"\\$message\""," _STORED_NOTES=\"\\${_STORED_NOTES}\\${message}\"","}","","# ─< Improved display function that only shows categories with content >──────────────────","display_stored_messages() {"," local has_messages=0",""," # ─< First check if we have any messages at all >─────────────────────────────────────────"," if [ -z \"\\$_STORED_ERRORS\" ] && [ -z \"\\$_STORED_WARNINGS\" ] && [ -z \"\\$_STORED_INFOS\" ] && [ -z \"\\$_STORED_NOTES\" ]; then"," return 0"," fi",""," # ─< Now display each non-empty category with proper spacing >────────────────────────────"," if [ -n \"\\$_STORED_ERRORS\" ]; then"," printf \"\\n\\${BOLD}\\${RED}=== Errors ===\\${NC}\\n\""," printf \"\\$_STORED_ERRORS\""," has_messages=1"," fi",""," if [ -n \"\\$_STORED_WARNINGS\" ]; then"," [ \"\\$has_messages\" -eq 1 ] && printf \"\\n\""," printf \"\\${BOLD}\\${YELLOW}=== Warnings ===\\${NC}\\n\""," printf \"\\$_STORED_WARNINGS\""," has_messages=1"," fi",""," if [ -n \"\\$_STORED_INFOS\" ]; then"," [ \"\\$has_messages\" -eq 1 ] && printf \"\\n\""," printf \"\\${BOLD}\\${CYAN}=== Info ===\\${NC}\\n\""," printf \"\\$_STORED_INFOS\""," has_messages=1"," fi",""," if [ -n \"\\$_STORED_NOTES\" ]; then"," [ \"\\$has_messages\" -eq 1 ] && printf \"\\n\""," printf \"\\${BOLD}\\${LIGHT_GREEN}=== Notes ===\\${NC}\\n\""," printf \"\\$_STORED_NOTES\""," fi","}"]},"shstruct + shdefault":{"prefix":["shstruct","shdefault"],"body":["#!/bin/sh","","# ╭───────────────╮","# │ env functions │","# ╰───────────────╯","# ───────────────────────────────────< ANSI color codes >───────────────────────────────────","RED='\\033[0;31m'","CYAN='\\033[0;36m'","YELLOW='\\033[0;33m'","LIGHT_GREEN='\\033[0;92m'","BOLD='\\033[1m'","NC='\\033[0m' # No Color","","echo_error() {"," printf \"\\${BOLD}\\${RED}ERROR: \\${NC}\\${RED}%s\\${NC}\\n\" \"\\$1\" >&2","}","","echo_info() {"," printf \"\\${BOLD}\\${CYAN}INFO: \\${NC}\\${CYAN}%s\\${NC}\\n\" \"\\$1\"","}","","echo_warning() {"," printf \"\\${BOLD}\\${YELLOW}WARNING: \\${NC}\\${YELLOW}%s\\${NC}\\n\" \"\\$1\"","}","","echo_note() {"," printf \"\\${BOLD}\\${LIGHT_GREEN}NOTE: \\${NC}\\${LIGHT_GREEN}%s\\${NC}\\n\" \"\\$1\"","}","","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}","","# ─────────────< Check if the user is root and set sudo variable if necessary >─────────────","check_root() {"," if [ \"\\$(id -u)\" -ne 0 ]; then"," if command_exists sudo; then"," echo_info \"User is not root. Using sudo for privileged operations.\""," _sudo=\"sudo\""," else"," echo_error \"No sudo found and you're not root! Can't install packages.\""," return 1"," fi"," else"," echo_info \"Root access confirmed.\""," _sudo=\"\""," fi","}","","# ──────────────────────< Check if the given command exists silently >──────────────────────","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}","","# ╭────────────────────────────────────╮","# │ insert your scripts/functions here │","# ╰────────────────────────────────────╯","${1:Your script here}","# ───────────────────────────────< main function to execute >───────────────────────────────","main() {"," if check_root; then"," else"," echo_error \"Something went terribly wrong!\""," fi","}","","main"]},"docker build script + build script":{"prefix":["docker build script","build script"],"body":["#!/usr/bin/env bash","# ─< ANSI color codes >───────────────────────────────────────────────────────────────────","RED='\\033[0;31m'","CYAN='\\033[0;36m'","NC='\\033[0m' # No Color","","echo_error() {"," printf \"\\${BOLD}\\${RED}ERROR: \\${NC}\\${RED}%s\\${NC}\\n\" \"\\$1\" >&2","}","","echo_info() {"," printf \"\\${BOLD}\\${CYAN}INFO: \\${NC}\\${CYAN}%s\\${NC}\\n\" \"\\$1\"","}","","# ─< Check if the given command exists silently >─────────────────────────────────────────","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}","","image=\"${1:image}\"","tag=\"${2:latest}\"","","if command_exists docker; then"," if [ -e ./Dockerfile ]; then"," docker build -t \"\\${image}:\\${tag}\" ."," else"," echo_error \"There was no dockerfile present in this directory: \\$PWD\""," fi","else"," echo_error \"Docker is not installed!\"","fi"]},"linux pkg install + build script":{"prefix":["linux pkg install","build script"],"body":["{"," #!/usr/bin/env bash",""," # ─< Check if the given command exists silently >─────────────────────────────────────────"," command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1"," }",""," getImports() {"," local url=\"\\$1\""," local import=\"\\$(mktemp)\""," 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\""," sleep 0.1"," rm -f \"\\$import\""," }",""," setup-env() {"," # 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.."," #"," # 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"," # dream ~= combined beddu and pika"," 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 pen; then"," getImports \\$dream"," fi"," }",""," getDependencies() {"," # INFO:"," # ╭─────────────────────────────────────────────────────────────────────────╮"," # │ You can define dependencies for various linux distros here. It will │"," # │ automagically be pulled via the \\$pkgArray[\\$distro] variable │"," # ╰─────────────────────────────────────────────────────────────────────────╯"," depsGeneral=()",""," depsDebian=()"," depsUbuntu=()"," depsFedora=()"," depsOpensuse=()"," depsArch=()"," depsAlpine=()",""," declare -A deps=("," [debian]=\"depsDebian\""," [ubuntu]=\"depsUbuntu\""," [fedora]=\"depsFedora\""," [arch]=\"depsArch\""," [alpine]=\"depsAlpine\""," [opensuse]=\"depsOpensuse\""," )",""," # INFO:"," # ╭────────────────────────────────────────────────────────────────╮"," # │ This variable stores the packages you provided for each distro │"," # ╰────────────────────────────────────────────────────────────────╯"," declare -n pkgArray=\"\\${deps[\\$distro]}\"",""," pkgArray=\"\\${pkgArray[@]} \\${depsGeneral[@]}\"",""," case \"\\$distro\" in"," debian | ubuntu | arch | fedora | alpine | opensuse)"," # installs packages inside the \\${pkgArray[@]} list, which is the \\$distro part of the confiruation above"," check-and-install \\${pkgArray[@]}"," ;;"," *)"," pen bold yellow \"There are no dependencies to install for \\$distro\""," return 0"," ;;"," esac"," }","","${2:#your-script-logic}",""," main() {"," if \\$silent; then"," pen yellow \"ARG: Executing script silently!\""," fi",""," if ! getDependencies; then"," throw \"Error when installing dependencies..\""," fi",""," case \"\\$distro\" in"," arch)"," echo \"arch\""," ;;"," debian)"," echo \"debian\""," ;;"," ubuntu)"," echo \"ubuntu\""," ;;"," fedora)"," echo \"fedora\""," ;;"," alpine)"," echo \"alpine\""," ;;"," opensuse)"," echo \"opensuse\""," ;;"," *)"," echo \"\\$distro is not supported by this script!\""," exit 69"," ;;"," esac"," }",""," if setup-env; then"," # ─< package variable >───────────────────────────────────────────────────────────────────"," unset PACKAGE",""," # ─< argument list variables >────────────────────────────────────────────────────────────"," silent=false",""," sleep 0.1",""," PACKAGE=${1:packagename}"," 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)"," export silent=true"," ;;"," esac"," done",""," main"," fi","}"]},"posix packager detection + get_packager":{"prefix":["posix packager detection","get_packager"],"body":["# ─< Distribution detection and installation >────────────────────────────────────────","get_packager() {"," if [ -e /etc/os-release ]; then"," echo_info \"Detecting distribution...\""," . /etc/os-release",""," # ─< Convert \\$ID and \\$ID_LIKE to lowercase >──────────────────────────────────────────────"," ID=\\$(printf \"%s\" \"\\$ID\" | tr '[:upper:]' '[:lower:]')"," ID_LIKE=\\$(printf \"%s\" \"\\$ID_LIKE\" | tr '[:upper:]' '[:lower:]')",""," case \"\\$ID\" in"," ubuntu | pop) ${1:inst_ubuntu} ;;"," debian) ${2:inst_debian} ;;"," fedora) ${3:inst_fedora} ;;"," alpine) inst_alpine ;;"," arch | manjaro | garuda | endeavour) ${4:inst_arch} ;;"," opensuse*) inst_opensuse ;;"," *)"," if [ \"\\${ID_LIKE#*debian}\" != \"\\$ID_LIKE\" ]; then"," ${2:inst_debian}"," elif [ \"\\${ID_LIKE#*ubuntu}\" != \"\\$ID_LIKE\" ]; then"," ${1:inst_ubuntu}"," elif [ \"\\${ID_LIKE#*arch}\" != \"\\$ID_LIKE\" ]; then"," ${4:inst_arch}"," elif [ \"\\${ID_LIKE#*fedora}\" != \"\\$ID_LIKE\" ]; then"," ${3:inst_fedora}"," elif [ \"\\${ID_LIKE#*suse}\" != \"\\$ID_LIKE\" ]; then"," inst_opensuse"," else"," echo_error \"Unsupported distribution: \\$ID\""," exit 1"," fi"," ;;"," esac"," else"," echo_error \"Unable to detect distribution. /etc/os-release not found.\""," exit 1"," fi","}"]},"command_exists":{"prefix":"command_exists","body":["# ─< Check if the given command exists silently >─────────────────────────────────────────","command_exists() {"," command -v \"\\$@\" >/dev/null 2>&1","}"]}} \ No newline at end of file