From fe93b5b3e50f2a8504609b25f5ac1850a03ec8ed Mon Sep 17 00:00:00 2001 From: pika <67532734+pik4li@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:39:28 +0100 Subject: [PATCH] addet git_installs --- .zsh/.installs.zsh | 62 ++++++++++++++++++++++++++++++++++++++++++++++ .zshrc | 8 ++++++ 2 files changed, 70 insertions(+) create mode 100644 .zsh/.installs.zsh diff --git a/.zsh/.installs.zsh b/.zsh/.installs.zsh new file mode 100644 index 0000000..1182eb5 --- /dev/null +++ b/.zsh/.installs.zsh @@ -0,0 +1,62 @@ +# ─< Helper functions >───────────────────────────────────────────────────────────────── +declare -a echo_messages + +function echo_error() { + local message="\033[0;1;31m❌ ERROR:\033[0;31m\t${*}\033[0m" + echo -e "$message" + echo_messages+=("$message") +} + +# Function to print all stored messages +function print_echo_messages() { + echo -e "\033[38;5;196mL\033[38;5;202mo\033[38;5;208mg\033[38;5;214m \033[38;5;220mo\033[38;5;226mu\033[38;5;118mt\033[38;5;46mp\033[38;5;48mu\033[38;5;51mt\033[38;5;45m:" + for msg in "${echo_messages[@]}"; do + echo -e "$msg" + done +} + +# ─< Check if the given command exists silently >───────────────────────────────────────── +command_exists() { + command -v "$@" >/dev/null 2>&1 +} + +packages=( + "brave" + "docker" + "neovide" + "neovim" + "xmrig" + "yazi" + "ytgo" +) + +_help() { + echo "Just use _install 'packagename' to install some packages" + echo "Available packages are:" + echo "${packages[@]}" +} + +_install_func() { + curl -fsSL "https://git.k4li.de/pika/scripts/raw/branch/main/bash/installs/${1}.sh" | sh +} + +_check() { + if ! command_exists curl; then + echo_error "curl was not found on this system!" + echo_error "exiting now!" + exit 1 + fi +} + +_install() { + case "$1" in + --help | -h) + _help + ;; + *) + if _check; then + _install_func "$1" + fi + ;; + esac +} diff --git a/.zshrc b/.zshrc index fc677db..e85452f 100644 --- a/.zshrc +++ b/.zshrc @@ -587,6 +587,13 @@ _environment() { [ -d "$HOME/.zsh/plugins/fzf-zsh-plugin/bin" ] && export PATH="$HOME/.zsh/plugins/fzf-zsh-plugin/bin:$PATH" } +git_installs() { + if [ -e "$HOME/.zsh/.install.sh" ]; then + echo_info "Git installs activated by '_install '" + . "$HOME/.zsh/.install.sh" + fi +} + _end() { if command_exists fastfetch; then clear && @@ -607,6 +614,7 @@ main() { _environment _coding_ _alias + git_installs _end }