commit b11d81cc5d55aea3d090b52227f344707bb49de1 Author: Aethrexal Date: Thu Jan 16 00:23:50 2025 +0100 Init commit diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..08658b3 --- /dev/null +++ b/.zshrc @@ -0,0 +1,86 @@ +# Set the directory we want to store zinit and plugins +ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" + +# Download Zinit, if it's not there yet +if [ ! -d "$ZINIT_HOME" ]; then + mkdir -p "$(dirname $ZINIT_HOME)" + git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" +fi + +# Source/Load zinit +source "${ZINIT_HOME}/zinit.zsh" + +eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/zen.toml)" + +# Add in zsh plugins +zinit light zsh-users/zsh-syntax-highlighting +zinit light zsh-users/zsh-completions +zinit light zsh-users/zsh-autosuggestions +zinit light Aloxaf/fzf-tab +zinit light djui/alias-tips + +# Add in snippets +zinit snippet OMZP::git +zinit snippet OMZP::archlinux +zinit snippet OMZP::command-not-found +zinit snippet OMZP::sudo +#zinit snippet OMZP::bun + +# Load completions +autoload -U compinit && compinit + +zinit cdreplay -q + +# Shell integrations +eval "$(fzf --zsh)" +eval "$(zoxide init --cmd cd zsh)" + +# Keybindings +# bindkey '^f' autosuggest-accept +bindkey -e +bindkey '^p' history-search-backward +bindkey '^n' history-search-forward + +# History +HISTSIZE=5000 +HISTFILE=~/.zsh_history +SAVEHIST=$HISTSIZE +HISTDUP=erase +setopt appendhistory +setopt sharehistory +setopt hist_ignore_space +setopt hist_ignore_all_dups +setopt hist_save_no_dups +setopt hist_ignore_dups +setopt hist_find_no_dups + +# Completion styling +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' +zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" +zstyle ':completion:*' menu no +zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath' +zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath' + +# Aliases +alias ls='ls --color=auto' +alias ll='ls -lav --ignore=..' # show long listing of all except ".." +alias l='ls -lav --ignore=.?*' # show long listing but no hidden dotfiles except "." +alias la='ls -A' +alias ..='cd ..' +alias mv='mv -i' +alias rm='rm -i' +alias vim='nvim' + +alias neo='neofetch' +alias hy='hyfetch' +alias npm='pnpm' +alias npx='pnpm dlx' +alias zed='zeditor' + +alias chall='~/Scripts/challenges.sh' +alias backup='~/Scripts/backup.sh' + +# Paths +PATH="$HOME/.npm-packages/bin:$PATH" +PATH="$HOME/.bun/bin:$PATH" +PATH="$HOME/.local/bin:$PATH" diff --git a/Scripts/challenges.sh b/Scripts/challenges.sh new file mode 100755 index 0000000..db4eab5 --- /dev/null +++ b/Scripts/challenges.sh @@ -0,0 +1,261 @@ +#!/usr/bin/env bash + +# Some things taken from here https://github.com/nmdra/Dotfiles/blob/main/scripts/birthday.sh + +jsonFile="/home/luna/NixOS/scripts/challengesData.json" + + +d="$((s / 60 / 60 / 24)) days" +h="$((s / 60 / 60 % 24)) hours" +m="$((s / 60 % 60)) minutes" + +# Remove plural if < 2. +((${d/ *} == 1)) && d=${d/s} +((${h/ *} == 1)) && h=${h/s} +((${m/ *} == 1)) && m=${m/s} + +# Hide empty fields. +((${d/ *} == 0)) && unset d +((${h/ *} == 0)) && unset h +((${m/ *} == 0)) && unset m + +uptime=${d:+$d, }${h:+$h, }$m +uptime=${uptime%', '} +uptime=${uptime:-$s seconds} + +function getInstallTime { + if [ -z "$1" ] + then + installTime=$(stat -c %W /) + else + installTime="$1" + fi + + echo $(echo $installTime | awk '{print strftime("%d/%m/%Y, %H:%M:%S", $1)}') +} + +function getPercentageDone { + # Define the function for calculating percentage completion + # Ty cerealkillerjohn (The Linux Cast Discord server) + target_date="$2" + start_date="$1" # Allow the start date to be passed as an argument + + current_date=$(date +"%Y-%m-%d %H:%M:%S") + + target_timestamp=$(date -d "$target_date" +"%s") + start_timestamp=$(date -d "$start_date" +"%s") + current_timestamp=$(date -d "$current_date" +"%s") + + if [ "$current_timestamp" -gt "$target_timestamp" ]; then + echo -e "\033[38;5;82m100% Complete\033[0m" # Green + else + total_time=$((target_timestamp - start_timestamp)) + elapsed_time=$((current_timestamp - start_timestamp)) + + percentage=$(awk "BEGIN {printf \"%.2f\", $elapsed_time * 100 / $total_time}") + + # Remove decimal part if it's .00 + percentage=$(echo "$percentage" | sed 's/\.00$//') + + if [ $(awk "BEGIN {print ($percentage <= 33.49) ? 1 : 0}") -eq 1 ]; then + echo -e "\033[38;5;196m$percentage% Complete\033[0m" # Red + elif [ $(awk "BEGIN {print ($percentage >= 34.50 && $percentage <= 66.49) ? 1 : 0}") -eq 1 ]; then + echo -e "\033[38;5;208m$percentage% Complete\033[0m" # Orange + elif [ $(awk "BEGIN {print ($percentage >= 67.50 && $percentage <= 99.99) ? 1 : 0}") -eq 1 ]; then + echo -e "\033[38;5;118m$percentage% Complete\033[0m" # Chartreuse Green + else + echo -e "\033[38;5;82m$percentage% Complete\033[0m" # Green + fi + fi +} + +function getProgressDone { + # All the Timing information + let Minute=60 + let Hour=3600 + let Day=86400 + let Week=604800 + + # Year_days=365.25 days # 4 years (1461 days cause leap year) Divided by 4 + # Month_days=30.4375 days # Year Divided by 12 + let Month=2629800 + let Year=31557600 + + # Calculation of everything needed + let current=$(date +%s) + + #let birth_install=$(stat -c %W /) # Comment out if using the custom Epoch + #let birth_install=1722801652 # Custom Epoch for Reinstalls + birth_install=$(date -d "$1" +"%s") + + let challenge_complete=(birth_install + Month * 2) + let diff_left=(challenge_complete - current) + let diff_done=(current - birth_install) + + let Years_done=(diff_done / Year) + let Months_done=(diff_done % Year / Month) + let Weeks_done=(diff_done % Month / Week) + let Days_done=(diff_done % Week / Day) + let Hours_done=(diff_done % Day / Hour) + let Minutes_done=(diff_done % Hour / Minute) + let Seconds_done=(diff_done % Minute) + + let Years_left=(diff_left / Year) + let Months_left=(diff_left % Year / Month) + let Weeks_left=(diff_left % Month / Week) + let Days_left=(diff_left % Week / Day) + let Hours_left=(diff_left % Day / Hour) + let Minutes_left=(diff_left % Hour / Minute) + let Seconds_left=(diff_left % Minute) + + + if [ $Years_done -gt 0 ] + then + finalString="$Years_done""y " + fi + + if [ $Months_done -gt 0 ] + then + finalString+="$Months_done""m " + fi + + if [ $Weeks_done -gt 0 ] + then + finalString+="$Weeks_done""w " + fi + + if [ $Days_done -gt 0 ] + then + finalString+="$Days_done""d " + fi + + if [ $Hours_done -gt 0 ] + then + finalString+="$Hours_done""h " + fi + + if [ $Minutes_done -gt 0 ] + then + finalString+="$Minutes_done""m " + fi + + if [ $Seconds_done -gt 0 ] + then + finalString+="$Seconds_done""s" + fi + + echo "$finalString" +} + + + + +## DEFINE COLORS +bold='' +red='' +green='' +yellow='' +blue='' +magenta='' +cyan='' +white='' +reset='' + +## USER VARIABLES -- YOU CAN CHANGE THESE +lc="${reset}${magenta}" # labels +hn="${reset}${bold}${blue}" # hostname +ic="${reset}${green}" # info +c1="${reset}${white}" # second color +c2="${reset}${yellow}" # third color + + +#echo +#getInstallTime $(date -d "$(jq -r '. | to_entries[] | select(.value.current).value.startDate' $jsonFile)" +"%s") +#echo + +#echo $(jq -r '. | to_entries[] | select(.value.current).value.startDate' $jsonFile) +#echo + + +#$(jq -r '. | to_entries[] | select(.value.current).value.startDate' $jsonFile) +#echo + +cat <