dotfiles

Dash Eclipse's dotfiles
git clone git://ezup.dev/dotfiles.git
Log | Files | Refs | README | LICENSE

commit b0b6c28591f0700cb7a0364144d77b8666a1c5af
parent 34b0cff2046f263f38aa98054245903cfb7d995e
Author: Dash Eclipse <dashezup@disroot.org>
Date:   Thu, 15 Jul 2021 14:15:58 +0000

feat: .zshrc.local: add more functions

zlibd(), mergelop(), ocr() and day_of_week()

Diffstat:
M.zshrc.local | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/.zshrc.local b/.zshrc.local @@ -204,3 +204,22 @@ showplot() { plot '-' using 1:2 with lines title '${#DATA[@]} items | $FDATE + ${DURATION}d = $LDATE' " } + +# https://unix.stackexchange.com/a/49066 +zlibd() (printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - "$@" | gzip -dc) + +# Gentoo emerge history +mergelop() { qlop -c -M | sort -hrk2 | sed -r 's/:| average| for| merges| merge//g' | awk '$2 < 86400 { cmd = "date -u +%T -d@" $2; print $1, ((cmd | getline res)>0)? res : $2, $3; close(cmd) }' | column -t | sk --no-sort; } + +ocr() { + grim -g "$(slurp)" - | tesseract - - 2>/dev/null +} + +day_of_week() { + # https://stackoverflow.com/a/36389289/15763223 + rtc_timestamp=$(</sys/class/rtc/rtc0/since_epoch) + rtc_date=$(</sys/class/rtc/rtc0/date) + dow=$(((rtc_timestamp/86400+4)%7)) + week=(Sunday Monday Tuesday Wednesday Thursday Friday Saturday) + echo "${rtc_date} ${week[@]:${dow}:1}" +}