Skip to content

Instantly share code, notes, and snippets.

@palaniraja
Last active November 1, 2022 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palaniraja/a132811e48cfb6a69efea0d8463eac98 to your computer and use it in GitHub Desktop.
Save palaniraja/a132811e48cfb6a69efea0d8463eac98 to your computer and use it in GitHub Desktop.
Geek tool scripts I use with my desktop
# to list todo's from todotxt file - refersh every 900 sec
cat /Users/palaniraja/Dropbox/Personal/orgmode/todo.txt | grep -v ^x\ | cut -c 12- | awk '{print "* " $0}'
# calendar events - next 5 days grouped by date - refresh every 1800 sec
/usr/local/bin/icalbuddy -nc -sd eventsToday+5
# previous month - refersh every 3600 sec
cal `date -v -1m "+%m %Y"`
# current month with today highlighted - refersh every 3600 sec
cal_head=`cal | head -1`; cal_tail=`cal | tail -7`; today=`date "+%e"`; echo "$cal_head"; echo "${cal_tail/${today}/\033[1;32m${today}\033[0m}";
# high-seirra
cal_head=`cal -h | head -1`; cal_tail=`cal -h | tail -7`; today=`date "+%e"`; echo "$cal_head"; printf "${cal_tail/${today}/\033[1;32m${today}\033[0m}"
# next month - refersh every 3600 sec
cal `date -v +1m "+%m %Y"`
@palaniraja
Copy link
Author

#!/usr/bin/env bash

# Progress Bar of Year, Month and Day: See the big picture.
#
# by Mucahit (http://github.com/mucahit)
#
# <bitbar.title>Progress Bar of Year, Month and Day</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Mucahit</bitbar.author>
# <bitbar.author.github>Mucahit</bitbar.author.github>
# <bitbar.desc>Progress Bar of Year, Month and Day: See the big picture.</bitbar.desc>
# <bitbar.image>https://user-images.githubusercontent.com/5108459/43047918-c946f6bc-8de7-11e8-940a-036f44087b92.jpg</bitbar.image>
# <bitbar.dependencies>bash</bitbar.dependencies>
# <bitbar.abouturl>https://gist.github.com/mucahit/0bd2ace80ded22328d0c638715a4911b</bitbar.abouturl>

width=20
fill_char="▄"
empty_char=""

bitbar="size=14 color=white font='Avenir'"

now=$(date +%s)

Y_start=$(date -j 01010000 +%s)
Y_end=$(date -jr "$Y_start" -v +1y +%s)
Y_progress=$(
    echo "($now - $Y_start) * 100 / ($Y_end - $Y_start)" | bc -l
)

m_start=$(date -j "$(date +%m)010000" +%s)
m_end=$(date -jr "$m_start" -v +1m +%s)
m_progress=$(
    echo "($now - $m_start) * 100 / ($m_end - $m_start)" | bc -l
)

d_start=$(date -j "$(date +%m%d)0000" +%s)
d_end=$(date -jr "$d_start" -v +1d +%s)
d_progress=$(
    echo "($now - $d_start) * 100 / ($d_end - $d_start)" | bc -l
)

round() { printf %.0f "$1"; }

progress() {
    filled=$(round "$(echo "$1 * $width / 100" | bc -l)")
    empty=$((width - filled))
    # repeat the characters using printf
    printf "$fill_char%0.s" $(seq "$filled")
    printf "$empty_char%0.s" $(seq "$empty")
}

# echo "$(round "$Y_progress")%"
# echo ---

# day + progress bar
echo "  Day: $(progress "$d_progress") $(round "$d_progress")%"

# month + progress bar
echo " "
echo "Month: $(progress "$m_progress") $(round "$m_progress")%"

# year + progress bar"
echo " "
echo " Year: $(progress "$Y_progress") $(round "$Y_progress")%"

@palaniraja
Copy link
Author

cal -h -A4 -B4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment