diff --git a/fancy-fre.sh b/fancy-fre.sh new file mode 100755 index 0000000..8ecb752 --- /dev/null +++ b/fancy-fre.sh @@ -0,0 +1,111 @@ +#!/usr/bin/env bash +set -euo pipefail + +TOOLS_FILE="$(dirname "$0")/tools.yaml" +LOGFILE="$(dirname "$0")/quick-install.log" + +log() { echo "[INFO] $(date '+%F %T') $*" | tee -a "$LOGFILE"; } +log_warn() { echo "[WARN] $(date '+%F %T') $*" | tee -a "$LOGFILE"; } +log_err() { echo "[ERROR] $(date '+%F %T') $*" | tee -a "$LOGFILE"; } + +require_tools() { + for tool in yq gum; do + if ! command -v "$tool" &>/dev/null; then + log_err "This script requires '$tool'. Please install it first." + exit 1 + fi + done +} + +get_tools_for_category() { + local category="$1" + yq e ".${category}[]" "$TOOLS_FILE" +} + +check_and_prepare_install_list() { + local category="$1" + local install_list=() + local ppas_to_add=() + + # Read each item (YAML block) in the category + local length + length=$(yq e "length(.${category})" "$TOOLS_FILE") + for i in $(seq 0 $((length - 1))); do + local name ppa + name=$(yq e ".${category}[$i].name" "$TOOLS_FILE") + ppa=$(yq e ".${category}[$i].ppa // \"\"" "$TOOLS_FILE") + + if ! command -v "$name" &>/dev/null; then + install_list+=("$name") + if [[ -n "$ppa" ]]; then + ppas_to_add+=("$ppa") + fi + fi + done + + # Remove duplicate PPAs + mapfile -t ppas_to_add < <(printf '%s\n' "${ppas_to_add[@]}" | sort -u) + + echo "${install_list[*]}" + echo "${ppas_to_add[*]}" +} + +install_category() { + local category="$1" + + log "Processing category: $category" + + read -r -a to_install ppas < <(check_and_prepare_install_list "$category") + + if [[ ${#to_install[@]} -eq 0 ]]; then + log "All tools in '$category' are already installed." + return + fi + + # Show the user what will be installed + gum style --foreground 212 --bold "Category: $category" + gum style --foreground 99 "The following tools will be installed:" + printf '%s\n' "${to_install[@]}" | gum format + + if ! gum confirm "Proceed with installing these tools?"; then + log_warn "User declined installation for category: $category" + return + fi + + # Add PPAs if any + if [[ ${#ppas[@]} -gt 0 ]]; then + for ppa in "${ppas[@]}"; do + log "Adding PPA: $ppa" + sudo add-apt-repository -y "$ppa" + done + sudo apt update + fi + + log "Installing packages for category: $category" + sudo apt install -y "${to_install[@]}" +} + +main() { + require_tools + log "Starting tool installation from $TOOLS_FILE" + + # Read all top-level categories from tools.yaml + mapfile -t categories < <(yq e 'keys | .[]' "$TOOLS_FILE") + + # Let user select categories to install + selected_categories=$(gum choose --no-limit --header "Select categories to install:" "${categories[@]}") + + if [[ -z "$selected_categories" ]]; then + log_warn "No categories selected. Exiting." + exit 0 + fi + + # Loop through selected categories and install + while IFS= read -r category; do + install_category "$category" + done <<< "$selected_categories" + + log "✅ All done." +} + +main "$@" diff --git a/fre.sh b/fre.sh index 8ecb752..cf89d3b 100755 --- a/fre.sh +++ b/fre.sh @@ -2,108 +2,63 @@ set -euo pipefail TOOLS_FILE="$(dirname "$0")/tools.yaml" -LOGFILE="$(dirname "$0")/quick-install.log" +LOGFILE="$(dirname "$0")/install.log" log() { echo "[INFO] $(date '+%F %T') $*" | tee -a "$LOGFILE"; } log_warn() { echo "[WARN] $(date '+%F %T') $*" | tee -a "$LOGFILE"; } log_err() { echo "[ERROR] $(date '+%F %T') $*" | tee -a "$LOGFILE"; } -require_tools() { - for tool in yq gum; do - if ! command -v "$tool" &>/dev/null; then - log_err "This script requires '$tool'. Please install it first." - exit 1 - fi - done -} - -get_tools_for_category() { - local category="$1" - yq e ".${category}[]" "$TOOLS_FILE" -} - -check_and_prepare_install_list() { - local category="$1" - local install_list=() - local ppas_to_add=() - - # Read each item (YAML block) in the category - local length - length=$(yq e "length(.${category})" "$TOOLS_FILE") - for i in $(seq 0 $((length - 1))); do - local name ppa - name=$(yq e ".${category}[$i].name" "$TOOLS_FILE") - ppa=$(yq e ".${category}[$i].ppa // \"\"" "$TOOLS_FILE") - - if ! command -v "$name" &>/dev/null; then - install_list+=("$name") - if [[ -n "$ppa" ]]; then - ppas_to_add+=("$ppa") - fi - fi - done - - # Remove duplicate PPAs - mapfile -t ppas_to_add < <(printf '%s\n' "${ppas_to_add[@]}" | sort -u) - - echo "${install_list[*]}" - echo "${ppas_to_add[*]}" +require_yq() { + if ! command -v yq &>/dev/null; then + log_err "This script requires 'yq'. Install it via 'sudo apt install yq'." + exit 1 + fi } install_category() { local category="$1" - log "Processing category: $category" - read -r -a to_install ppas < <(check_and_prepare_install_list "$category") + # Loop over all items under the category + local tools + tools=$(yq e ".${category}[]" "$TOOLS_FILE" | sed 's/^- //') - if [[ ${#to_install[@]} -eq 0 ]]; then - log "All tools in '$category' are already installed." - return - fi + local install_list=() + while IFS= read -r item; do + local tool + tool=$(yq e ".${category}[] | select(.name == \"$item\") | .name // \"$item\"" "$TOOLS_FILE") + local ppa + ppa=$(yq e ".${category}[] | select(.name == \"$item\") | .ppa // \"\"" "$TOOLS_FILE") - # Show the user what will be installed - gum style --foreground 212 --bold "Category: $category" - gum style --foreground 99 "The following tools will be installed:" - printf '%s\n' "${to_install[@]}" | gum format + if command -v "$tool" &>/dev/null; then + log "$tool already installed, skipping." + else + if [[ -n "$ppa" ]]; then + log "Adding PPA: $ppa for $tool" + sudo add-apt-repository -y "$ppa" + fi + install_list+=("$tool") + fi + done <<< "$tools" - if ! gum confirm "Proceed with installing these tools?"; then - log_warn "User declined installation for category: $category" - return - fi - - # Add PPAs if any - if [[ ${#ppas[@]} -gt 0 ]]; then - for ppa in "${ppas[@]}"; do - log "Adding PPA: $ppa" - sudo add-apt-repository -y "$ppa" - done + if [[ ${#install_list[@]} -gt 0 ]]; then + log "Installing: ${install_list[*]}" sudo apt update + sudo apt install -y "${install_list[@]}" + else + log "All tools in $category already installed." fi - - log "Installing packages for category: $category" - sudo apt install -y "${to_install[@]}" } main() { - require_tools + require_yq log "Starting tool installation from $TOOLS_FILE" - # Read all top-level categories from tools.yaml - mapfile -t categories < <(yq e 'keys | .[]' "$TOOLS_FILE") - - # Let user select categories to install - selected_categories=$(gum choose --no-limit --header "Select categories to install:" "${categories[@]}") - - if [[ -z "$selected_categories" ]]; then - log_warn "No categories selected. Exiting." - exit 0 - fi - - # Loop through selected categories and install - while IFS= read -r category; do + # Define which categories to process + local categories=("necessities" "modern" "privacy") + for category in "${categories[@]}"; do install_category "$category" - done <<< "$selected_categories" + done log "✅ All done." } diff --git a/tools.yaml b/tools.yaml index b8c7edc..57e004e 100644 --- a/tools.yaml +++ b/tools.yaml @@ -3,25 +3,27 @@ necessities: - apt - apt-utils + - btop - curl - fd-find - fzf - git - gnupg - gzip + - helix - jq - less - - lsb-release + - mtr - nala - ncdu - - net-tools + # - net-tools + - parallel - ripgrep - sed - - sudo + - stow - tar + - tldr - tmux - - tree - - unzip - util-linux - vim - wget @@ -41,12 +43,10 @@ privacy: - mat2 - mullvad-browser - protonvpn-cli - - protonvpn-stable-release - veracrypt modern_cli: - bat - - btop - delta - duf - dust @@ -54,14 +54,12 @@ modern_cli: - exa - fd-find - gitui - - helix - micro - most - nnn - procs - silversearcher-ag - taskwarrior - - tldr - tig dev: @@ -72,6 +70,8 @@ dev: - docker-compose - gcc-12-base - jq + - lazydocker + - lazygit - libclang-dev - npm - openjdk-17-jre @@ -86,7 +86,6 @@ desktop: - cmatrix - feh - flameshot - - kitty - neofetch - onlyoffice-desktopeditors - pdfsam diff --git a/zsh/.aliases b/zsh/.aliases index 3350fc2..66810a6 100644 --- a/zsh/.aliases +++ b/zsh/.aliases @@ -47,9 +47,10 @@ fi # ---------------------------- alias a='~/arsenal/run -t' +alias any='~/AnythingLLMDesktop/start' alias c='clear' -alias d=docker -alias dc=docker-compose +alias d='docker' +alias dc='docker-compose' # alias h='history' f() { fd $1 -exec bat {} + @@ -148,6 +149,18 @@ fi # alias allcmds='compgen -c | sort -u | fzf' +# ---------------------------- +# Taskwarrior +# ---------------------------- + +alias t='task' +alias tl='task list' +alias twa='task add' +tm() { + task modify +} +alias tb='task burndown.daily' + # ---------------------------- # Miscellaneous # ---------------------------- diff --git a/zsh/.zshrc b/zsh/.zshrc index 4a02405..b2373f2 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -95,17 +95,17 @@ source /usr/share/doc/pkgfile/command-not-found.zsh # >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! -__conda_setup="$('/home/e/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)" -if [ $? -eq 0 ]; then - eval "$__conda_setup" -else - if [ -f "/home/e/miniconda3/etc/profile.d/conda.sh" ]; then - . "/home/e/miniconda3/etc/profile.d/conda.sh" - else - export PATH="/home/e/miniconda3/bin:$PATH" - fi -fi -unset __conda_setup +# __conda_setup="$('/home/e/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)" +# if [ $? -eq 0 ]; then +# eval "$__conda_setup" +# else +# if [ -f "/home/e/miniconda3/etc/profile.d/conda.sh" ]; then +# . "/home/e/miniconda3/etc/profile.d/conda.sh" +# else +# export PATH="/home/e/miniconda3/bin:$PATH" +# fi +# fi +# unset __conda_setup # <<< conda initialize <<<