diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 23121b0..ac02a6f 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -2,7 +2,7 @@ export GOPATH="$HOME/go" export PATH=$PATH:$HOME/.local/bin:$GOPATH/bin:$HOME/scripts -source ./themes/inkletblotsh.zsh +source "$ZDOTDIR/themes/inkletblotsh.zsh" # Enable colors and change prompt: autoload -U colors && colors # Load colors diff --git a/.local/bin/bash-status-git b/.local/bin/bash-status-git index 9d297a3..31e9cd1 100755 --- a/.local/bin/bash-status-git +++ b/.local/bin/bash-status-git @@ -1,22 +1,83 @@ #!/bin/bash -if git status &>/dev/null; then - branch=$(git branch --show-current) +# Thanks alrra, https://github.com/alrra/dotfiles/blob/main/src/shell/bash_prompt - if [ -z "$branch" ]; then - echo "(detached)" - exit 0 - fi +branchName="" +tmp="" +sync="" + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Check if the current directory is in a Git repository. + +! git rev-parse &>/dev/null \ + && exit + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Check if in `.git/` directory (some of the following +# checks don't make sense/won't work in the `.git` directory). + +[ "$(git rev-parse --is-inside-git-dir)" == "true" ] \ + && exit + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Check for uncommitted changes in the index. + +if ! git diff --quiet --ignore-submodules --cached; then + tmp="$tmp+"; +fi + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Check for unstaged changes. + +if ! git diff-files --quiet --ignore-submodules --; then + tmp="$tmp*"; +fi + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Check for untracked files. + +if [ -n "$(git ls-files --others --exclude-standard)" ]; then + tmp="$tmp?"; +fi + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Check for stashed files. + +if git rev-parse --verify refs/stash &>/dev/null; then + tmp="$tmp""[s]"; +fi + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +[ -z "$tmp" ] && \ + tmp="~"; + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +branchName="$( printf "%s" "$( git rev-parse --abbrev-ref HEAD 2> /dev/null \ + || git rev-parse --short HEAD 2> /dev/null \ + || printf " (unknown)" )" | \ +tr -d "\n" )" + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Count how many commits behind and ahead we are. + +if git rev-list --left-right --count "$branchName"...origin/"$branchName" &>/dev/null; then + read -ra counts <<< "$(git rev-list --left-right --count "$branchName"...origin/"$branchName")" - read -ra counts <<< "$(git rev-list --left-right --count "$branch"...origin/"$branch")" to_push=${counts[0]} to_pull=${counts[1]} - extras=$([[ ${counts[0]} -eq 0 && ${counts[1]} -eq 0 ]] || echo " $to_push↑ $to_pull↓") - - if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then - echo "($branch*$extras)" - else - echo "($branch~$extras)" - fi + sync=$([[ ${counts[0]} -eq 0 && ${counts[1]} -eq 0 ]] || echo " $to_push↑ $to_pull↓") fi + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +printf "%s" "($branchName$tmp$sync)" diff --git a/.local/bin/cron/checkup b/.local/bin/cron/checkup index ea0f6d0..cae1011 100755 --- a/.local/bin/cron/checkup +++ b/.local/bin/cron/checkup @@ -1,6 +1,7 @@ #!/bin/sh # Syncs repositories and downloads updates, meant to be run as a cronjob. +# make sure you have set up passwordless sudo in SUDOERS file for this script notify-send "Repository Sync" "Checking for package updates..." @@ -8,6 +9,8 @@ sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates. Check your internet connection, if pacman is already running, or run update manually to see errors." +pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" + if pacman -Qu | grep -v "\[ignored\]" then notify-send "Repository Sync" "Sync comelete. You have updates $(pacman -Qu | grep -vc "\[ignored\]") available." diff --git a/.local/bin/status-vol b/.local/bin/status-vol index 1288d4c..3828a39 100755 --- a/.local/bin/status-vol +++ b/.local/bin/status-vol @@ -15,14 +15,15 @@ split() { set -- $1 printf '%s' "$@" } + vol="$(split "$vol" ".")" vol="${vol##0}" case 1 in $((vol >= 70)) ) icon="" ;; -$((vol >= 30)) ) icon="" ;; -$((vol >= 1)) ) icon="" ;; -* ) echo  && exit ;; + $((vol >= 30)) ) icon="" ;; + $((vol >= 1)) ) icon="" ;; + * ) echo " " && exit ;; esac echo "$icon $vol%"