Init commit
This commit is contained in:
86
.zshrc
Normal file
86
.zshrc
Normal file
@ -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"
|
261
Scripts/challenges.sh
Executable file
261
Scripts/challenges.sh
Executable file
@ -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='[1m'
|
||||
red='[31m'
|
||||
green='[32m'
|
||||
yellow='[33m'
|
||||
blue='[34m'
|
||||
magenta='[35m'
|
||||
cyan='[36m'
|
||||
white='[37m'
|
||||
reset='[0m'
|
||||
|
||||
## 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 <<EOF
|
||||
${yellow} ${blue} ${magenta} ${cyan} ${red} ${green} ${red} ${yellow} ${green} ${blue} ${reset}Challenges ${magenta} ${cyan} ${red} ${green} ${red} ${yellow} ${red} ${green} ${red} ${cyan} ${reset}
|
||||
EOF
|
||||
|
||||
# THIS NEEDS TO BE LAST
|
||||
|
||||
I=0
|
||||
while [ ! $I -eq $(jq '.challenges | length' $jsonFile) ];
|
||||
do
|
||||
title=$(jq -r .challenges[$I].title $jsonFile)
|
||||
startDate=$(jq -r .challenges[$I].startDate $jsonFile)
|
||||
endDate=$(jq -r .challenges[$I].endDate $jsonFile)
|
||||
lasted=$(jq -r .challenges[$I].lasted $jsonFile)
|
||||
procentDone=$(jq -r .challenges[$I].procentDone $jsonFile)
|
||||
reinstalls=$(jq -r .challenges[$I].reinstalls $jsonFile)
|
||||
current=$(jq -r .challenges[$I].current $jsonFile)
|
||||
|
||||
cat <<EOF
|
||||
$(if $current; then echo $yellow$bold"$title"$reset; else echo $green$bold"$title"$reset; fi)
|
||||
${cyan}${reset} ${startDate}
|
||||
EOF
|
||||
|
||||
if [ ! -z "$endDate" ] && [ -z "$procentDone" ]
|
||||
then
|
||||
cat <<EOF
|
||||
${cyan}${reset} ${endDate} | ${cyan}${reset} $(getPercentageDone "$startDate" "$endDate")
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ ! -z "$procentDone" ]
|
||||
then
|
||||
cat <<EOF
|
||||
${cyan}${reset} ${endDate} | ${cyan}${reset} ${red}$procentDone
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ ! -z "$lasted" ]
|
||||
then
|
||||
cat <<EOF
|
||||
${cyan}${reset} ${lasted}
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [[ "$title" == *"NixOS"* ]] && $current
|
||||
then
|
||||
generations=`readlink /nix/var/nix/profiles/system | cut -d- -f2`
|
||||
|
||||
if [ "$generations" -ge "1" ]
|
||||
then
|
||||
generations+=" Generations"
|
||||
else
|
||||
generations+=" Generation"
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
${cyan}${reset} ${generations}
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ "$reinstalls" -gt "0" ]
|
||||
then
|
||||
cat <<EOF
|
||||
${cyan}${reset} ${reinstalls}
|
||||
EOF
|
||||
fi
|
||||
|
||||
if $current
|
||||
then
|
||||
cat <<EOF
|
||||
${cyan}${reset} $(getProgressDone "$startDate")
|
||||
EOF
|
||||
fi
|
||||
|
||||
((I++))
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
${yellow} ${blue} ${magenta} ${cyan} ${red} ${green} ${red} ${yellow} ${green} ${blue} ${green} ${magenta} ${cyan} ${red} ${magenta} ${cyan} ${red} ${green} ${red} ${yellow} ${red} ${green} ${red} ${cyan} ${red} ${green} ${reset}
|
||||
EOF
|
59
Scripts/challengesData.json
Normal file
59
Scripts/challengesData.json
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"installEpoch": "1736967026",
|
||||
"challenges": [
|
||||
{
|
||||
"title": "Nobara 2 Months",
|
||||
"startDate": "2023-11-26 20:32:12",
|
||||
"endDate": "2024-01-26 20:32:12",
|
||||
"lasted": "",
|
||||
"procentDone": "",
|
||||
"reinstalls": 0,
|
||||
"current": false
|
||||
},
|
||||
{
|
||||
"title": "EndeavourOS",
|
||||
"startDate": "2024-07-04 03:56:25",
|
||||
"endDate": "",
|
||||
"lasted": "1m 3d 13h 19m 29s",
|
||||
"procentDone": "",
|
||||
"reinstalls": 0,
|
||||
"current": false
|
||||
},
|
||||
{
|
||||
"title": "Bazzite",
|
||||
"startDate": "2024-08-10 02:01:23",
|
||||
"endDate": "",
|
||||
"lasted": "2w 6d 18h 47m 29s",
|
||||
"procentDone": "",
|
||||
"reinstalls": 0,
|
||||
"current": false
|
||||
},
|
||||
{
|
||||
"title": "EndeavourOS 6 Months",
|
||||
"startDate": "2024-09-13 21:41:03",
|
||||
"endDate": "2025-03-13 21:41:03",
|
||||
"lasted": "2m 2w 2h 15m 32s",
|
||||
"procentDone": "42.58",
|
||||
"reinstalls": 0,
|
||||
"current": false
|
||||
},
|
||||
{
|
||||
"title": "NixOS Beat Alxhr (+17 Days)",
|
||||
"startDate": "2024-12-02 01:17:25",
|
||||
"endDate": "2025-01-15 07:03:00",
|
||||
"lasted": "",
|
||||
"procentDone": "",
|
||||
"reinstalls": 0,
|
||||
"current": false
|
||||
},
|
||||
{
|
||||
"title": "Bazzite 2 Months",
|
||||
"startDate": "2025-01-15 19:50:26",
|
||||
"endDate": "2025-03-15 19:50:26",
|
||||
"lasted": "",
|
||||
"procentDone": "",
|
||||
"reinstalls": 0,
|
||||
"current": true
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user