From db7ac16675938e5960b624d31426f104e5ef616d Mon Sep 17 00:00:00 2001 From: pika Date: Thu, 22 May 2025 12:01:12 +0200 Subject: [PATCH] changes. --- .zsh/.aliases.zsh | 39 +++++++++++++++++++++++++++++++++++++++ .zsh/.installs.zsh | 32 +++++++++++++++++--------------- .zshrc | 36 +++++++++++++++++++++++++++--------- 3 files changed, 83 insertions(+), 24 deletions(-) diff --git a/.zsh/.aliases.zsh b/.zsh/.aliases.zsh index 252ef6e..7b1f047 100644 --- a/.zsh/.aliases.zsh +++ b/.zsh/.aliases.zsh @@ -1,3 +1,11 @@ +# Define color variables +RED='\033[0;31m' +YELLOW='\033[0;33m' +CYAN='\033[0;36m' +GREEN='\033[1;32m' +NC='\033[0m' # No Color +BOLD='\033[1m' + # INFO: # ╭──────────╮ # │ defaults │ @@ -587,6 +595,37 @@ missing() { done } +# INFO: +# ╭─────────────────╮ +# │ other functions │ +# ╰─────────────────╯ +source-script() { + local url="$1" + local import="$(mktemp)" + + # ─< if $1 is a local file, source this one instead >───────────────────────────────────── + if [ -f "$url" ]; then + source "$url" + sleep 0.1 + return 0 + else + echo_info "Sourcing external script:${NC} $url" + # ─< 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" + sleep 0.1 + rm -f "$import" + fi +} + main() { # ─< g stands for GIT >───────────────────────────────────────────────────────────────────── if command_exists git; then diff --git a/.zsh/.installs.zsh b/.zsh/.installs.zsh index ee03a14..68d8ec9 100644 --- a/.zsh/.installs.zsh +++ b/.zsh/.installs.zsh @@ -41,21 +41,23 @@ _check() { } _install() { - case "$1" in - --help | -h) - _help - ;; - nvim) - if _check; then - _install_func "neovim" - fi - ;; - *) - if _check; then - _install_func "$@" - fi - ;; - esac + for arg in "$@"; do + case "arg" in + --help | -h) + _help + ;; + nvim) + if _check; then + _install_func "neovim" + fi + ;; + *) + if _check; then + _install_func "$@" + fi + ;; + esac + done } # _setup(){ diff --git a/.zshrc b/.zshrc index 471653f..3f8fbf6 100644 --- a/.zshrc +++ b/.zshrc @@ -38,19 +38,19 @@ BOLD='\033[1m' # Functions to store messages echo_error() { - _MESSAGES[error]+="${RED}❌ $1${NC}\n" + _MESSAGES[error]+="${RED}❌ $@${NC}\n" } echo_missing() { - _MESSAGES[missing]+="${YELLOW} 󱥸 $1${NC}\n" + _MESSAGES[missing]+="${YELLOW} 󱥸 $@${NC}\n" } echo_warning() { - _MESSAGES[warn]+="${YELLOW}⚠️ $1${NC}\n" + _MESSAGES[warn]+="${YELLOW}⚠️ $@${NC}\n" } echo_info() { - _MESSAGES[info]+="${CYAN}ℹ️ $1${NC}\n" + _MESSAGES[info]+="${CYAN}ℹ️ $@${NC}\n" } # Display stored messages @@ -113,36 +113,54 @@ __get_Packager__() { case "$DISTRO" in *debian*) + pkg_install() { + if command_exists nala; then + $_sudo nala install --assume-yes "$@" + else + $_sudo apt install --assume-yes "$@" + fi + } + if command_exists nala; then alias search="nala search" - alias install="$_sudo nala install --assume-yes" alias update="$_sudo nala update && $_sudo nala upgrade --full" alias remove="$_sudo nala purge" else alias search="apt-cache search" - alias install="$_sudo apt install --yes" alias update="$_sudo apt update && $_sudo apt upgrade" alias remove="$_sudo apt purge" fi + alias unbreak="$_sudo dpkg --configure -a" + alias install="pkg_install" ;; *arch*) + pkg_install() { + if command_exists paru; then + paru -S --color always --noconfirm --needed "$@" + elif command_exists yay; then + yay -S --color always --noconfirm --needed "$@" + else + $_sudo pacman -S --color always --noconfirm --needed "$@" + fi + } if command_exists paru; then alias search="paru -Ss --color always" - alias install="paru -S --color always --noconfirm" + # alias install="paru -S --color always --noconfirm" alias update="paru -Syu --color always" alias remove="paru -R --color always" elif command_exists yay; then alias search="yay -Ss --color always" - alias install="yay -S --noconfirm --color always" + # alias install="yay -S --noconfirm --color always" alias update="yay -Syu --color always" alias remove="yay -R --color always" else alias search="$_sudo pacman -Ss --color always" - alias install="$_sudo pacman -S --noconfirm --color always" + # alias install="$_sudo pacman -S --noconfirm --color always" alias update="$_sudo pacman -Syu --color always" alias remove="$_sudo pacman -R --color always" fi + alias install="pkg_install" ;; *rhel* | *fedora*) alias search="dnf search"