From 4e322bd98912f0c652a52397994fe6ffdf611571 Mon Sep 17 00:00:00 2001 From: 4ndr0666 <97570105+4ndr0666@users.noreply.github.com> Date: Sun, 22 Dec 2024 06:25:29 -0600 Subject: [PATCH] Auto-commit: 0 added, 1 modified, 0 deleted --- 4ndr0base.sh | 124 +++++++++++++++----- Git/{scripts => tests}/integration_tests.sh | 0 Git/workflows/shellcheck.yml | 39 ++++++ Git/workflows/typos.yml | 15 +++ 4 files changed, 147 insertions(+), 31 deletions(-) rename Git/{scripts => tests}/integration_tests.sh (100%) create mode 100644 Git/workflows/shellcheck.yml create mode 100644 Git/workflows/typos.yml diff --git a/4ndr0base.sh b/4ndr0base.sh index 2f746b4..35457fd 100755 --- a/4ndr0base.sh +++ b/4ndr0base.sh @@ -1,28 +1,88 @@ -#!/bin/bash -# File: 4ndr0baseinstall.sh +#!/bin/sh -e +# File: 4ndr0base.sh # Author: 4ndr0666 +## Description: Quick setup script for basic requirements on a new machine. # ============================== // 4NDR0BASEINSTALL.SH // # --- // Colors: -#tput setaf 0 = black -#tput setaf 1 = red -#tput setaf 2 = green -#tput setaf 3 = yellow -#tput setaf 4 = dark blue -#tput setaf 5 = purple -#tput setaf 6 = cyan -#tput setaf 7 = gray -#tput setaf 8 = light blue +RC='\033[0m' +RED='\033[31m' +YELLOW='\033[33m' +CYAN='\033[36m' +GREEN='\033[32m' + +## --- // File creation from DL: +#populate_configs() { +# printf "%b\n" "${YELLOW}Copying configuration files...${RC}" +# if [ -d "${HOME}/.config/EXAMPLE" ] && [ ! -d "${HOME}/.config/EXAMPLE-bak" ]; then +# cp -r "${HOME}/.config/EXAMPLE" "${HOME}/.config/EXAMPLE-bak" +# fi +# mkdir -p "${HOME}/.config/EXAMPLE/" +# curl -sSLo "${HOME}/.config/EXAMPLE/EXAMPLE.conf" https://github.com/4ndr0666/dotfiles/raw/main/config/EXAMPLE/EXAMPLE.conf +# curl -sSLo "${HOME}/.config/EXAMPLE/EXAMPLE.conf" https://github.com/4ndr0666/dotfiles/raw/main/config/EXAMPLE/EXAMPLE.conf +#} + +## --- // Check, make and append to file: +## Ensure /etc/zsh/zshenv sets ZDOTDIR to the user's config directory +#[ ! -f /etc/zsh/zshenv ] && "$ESCALATION_TOOL" mkdir -p /etc/zsh && "$ESCALATION_TOOL" touch /etc/zsh/zshenv +#echo "export ZDOTDIR=\"$HOME/.config/zsh\"" | "$ESCALATION_TOOL" tee -a /etc/zsh/zshenv # --- // Base Pkgs: -install_packages() { - sudo pacman -Sy - sudo pacman -S github-cli git-delta \ - lsd eza fd micro expac pacdiff \ - xorg-xhost xclip \ - ripgrep diffuse neovim --noconfirm - yay -Sy - yay -S bashmount-git debugedit lf-git --noconfirm +setup_base() { + sudo pacman -Sy --noconfirm --needed base-devel unzip archlinux-keyring github-cli git-delta lsd eza fd micro expac \ + bat bash-completion pacdiff xorg-xhost xclip ripgrep diffuse neovim + yay -Sy --noconfirm zsh-syntax-highlighting zsh-autosuggestions bashmount-git debugedit lf-git +} + +# --- // Nerd Font: +setup_font() { + FONT_DIR="$HOME/.local/share/fonts" + FONT_ZIP="$FONT_DIR/Meslo.zip" + FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip" + FONT_INSTALLED=$(fc-list | grep -i "Meslo") + if [ -n "$FONT_INSTALLED" ]; then + printf "%b\n" "${GREEN}Meslo Nerd-fonts are already installed.${RC}" + return 0 + fi + if [ ! -d "$FONT_DIR" ]; then + mkdir -p "$FONT_DIR" || { + printf "%b\n" "${RED}Failed to create directory: $FONT_DIR${RC}" + return 1 + } + else + printf "%b\n" "${GREEN}$FONT_DIR exists, skipping creation.${RC}" + fi + if [ ! -f "$FONT_ZIP" ]; then + # Download the font zip file + curl -sSLo "$FONT_ZIP" "$FONT_URL" || { + printf "%b\n" "${RED}Failed to download Meslo Nerd-fonts from $FONT_URL${RC}" + return 1 + } + else + printf "%b\n" "${GREEN}Meslo.zip already exists in $FONT_DIR, skipping download.${RC}" + fi + if [ ! -d "$FONT_DIR/Meslo" ]; then + mkdir -p "$FONT_DIR/Meslo" || { + printf "%b\n" "${RED}Failed to create directory: $FONT_DIR/Meslo${RC}" + return 1 + } + unzip "$FONT_ZIP" -d "$FONT_DIR" || { + printf "%b\n" "${RED}Failed to unzip $FONT_ZIP${RC}" + return 1 + } + else + printf "%b\n" "${GREEN}Meslo font files already unzipped in $FONT_DIR, skipping unzip.${RC}" + fi + rm "$FONT_ZIP" || { + printf "%b\n" "${RED}Failed to remove $FONT_ZIP${RC}" + return 1 + } + fc-cache -fv || { + printf "%b\n" "${RED}Failed to rebuild font cache${RC}" + return 1 + } + + printf "%b\n" "${GREEN}Meslo Nerd-fonts installed successfully${RC}" } # --- // Zsh: @@ -34,12 +94,9 @@ setup_zsh() { mkdir -p "$CONIFIG_DIR" fi - # Write the configuration to .zshrc cat <"$ZSHRC_FILE" # =========================================== // 4NDR0666_ZSHRC // -PROMPT='%F{32}%n%f%F{166}@%f%F{64}%m:%F{166}%~%f%F{15}$%f ' -RPROMPT='%F{15}(%F{166}%D{%H:%M}%F{15})%f' - +# --- // History: HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/history" HISTSIZE=10000000 SAVEHIST=10000000 @@ -47,20 +104,25 @@ setopt extended_glob setopt autocd setopt interactive_comments -# --- // Press `h` for cmd history: -h() { if [ -z "$*" ]; then history 1; else history 1 | egrep "$@"; fi; } # +# --- // Soloarized prompt: +PROMPT='%F{32}%n%f%F{166}@%f%F{64}%m:%F{166}%~%f%F{15}$%f ' +RPROMPT='%F{15}(%F{166}%D{%H:%M}%F{15})%f' +# --- // Aliased 'h' for cmd history: +h() { if [ -z "$*" ]; then history 1; else history 1 | egrep "$@"; fi; } + +# --- // Source the files: [ -f "$HOME/.config/zsh/aliasrc" ] && source "$HOME/.config/zsh/aliasrc" [ -f "$HOME/.config/zsh/functions.zsh" ] && source "$HOME/.config/zsh/functions.zsh" [ -f "$HOME/.config/zsh/.zprofile" ] && source "$HOME/.config/zsh/.zprofile" [ -d "/usr/share/zsh/plugins/zsh-autosuggestions" ] && source "/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" 2>/dev/null -[ -d "/usr/share/zsh/plugins/fast-syntax-highlighting" ] && source "/usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh" 2>/dev/null +[ -d "/usr/share/zsh/plugins/zsh-syntax-highlighting" ] && source "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" 2>/dev/null EOL - ln -s "$ZSHRC_FILE" $HOME/.zshrc || echo "Failed to create symlink for zsh config." - # Ensure /etc/zsh/zshenv sets ZDOTDIR to the user's config directory - #[ ! -f /etc/zsh/zshenv ] && "$ESCALATION_TOOL" mkdir -p /etc/zsh && "$ESCALATION_TOOL" touch /etc/zsh/zshenv - #echo "export ZDOTDIR=\"$HOME/.config/zsh\"" | "$ESCALATION_TOOL" tee -a /etc/zsh/zshenv + # --- // Create the symlink: + ln -svf "$ZSHRC_FILE" "$HOME/.zshrc" || { + printf "%b\n" "${RED}Failed to create symlink for .zshrc${RC}" + exit 1 + } } - diff --git a/Git/scripts/integration_tests.sh b/Git/tests/integration_tests.sh similarity index 100% rename from Git/scripts/integration_tests.sh rename to Git/tests/integration_tests.sh diff --git a/Git/workflows/shellcheck.yml b/Git/workflows/shellcheck.yml new file mode 100644 index 0000000..e3be746 --- /dev/null +++ b/Git/workflows/shellcheck.yml @@ -0,0 +1,39 @@ +name: Script Checks + +on: + pull_request: + paths: + - '**/*.sh' + workflow_dispatch: + +permissions: + contents: read + pull-requests: write + +jobs: + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Run ShellCheck + uses: reviewdog/action-shellcheck@v1 + with: + shellcheck_flags: '--source-path=${{ github.workspace }}/.shellcheckrc' + reviewdog_flags: '-fail-level=any' + + shfmt: + name: Shell Fomatting + runs-on: ubuntu-latest + needs: shellcheck + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Run shfmt + uses: reviewdog/action-shfmt@v1 + with: + shfmt_flags: '-i 4 -ci' + reviewdog_flags: '-fail-level=any' diff --git a/Git/workflows/typos.yml b/Git/workflows/typos.yml new file mode 100644 index 0000000..864dfc3 --- /dev/null +++ b/Git/workflows/typos.yml @@ -0,0 +1,15 @@ +name: Check for typos + +on: + [push, pull_request, workflow_dispatch] + +jobs: + check-typos: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - run: git fetch origin ${{ github.base_ref }} + + - name: Run spellcheck + uses: crate-ci/typos@v1.26.0