Skip to content

Instantly share code, notes, and snippets.

@rms1000watt
Last active December 18, 2019 20:25
Show Gist options
  • Save rms1000watt/d032112b8a62f8e185027bd7a6da244f to your computer and use it in GitHub Desktop.
Save rms1000watt/d032112b8a62f8e185027bd7a6da244f to your computer and use it in GitHub Desktop.
BitBar Plugins: Docker Stats, Netstats, Timezones, Refresh
#!/usr/bin/env bash
arr=()
arr[0]="[AU] $(TZ=Australia/Melbourne date +'%I:%M %p')"
arr[1]="[LA] $(TZ=America/Los_Angeles date +'%I:%M %p')"
arr[2]="[TX] $(TZ=US/Central date +'%I:%M %p')"
arr[3]="[NY] $(TZ=America/New_York date +'%I:%M %p')"
rand=$[$RANDOM % ${#arr[@]}]
echo "${arr[$rand]} | size=12"
echo "---"
IFS="\n"
for a in ${arr[@]}; do
echo "${a}"
done
echo "---"
echo "Refresh Stats | terminal=false refresh=true"
#!/usr/bin/env bash
# <bitbar.title>Docker Info</bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author>Ryan Smith</bitbar.author>
# <bitbar.author.github>rms1000watt</bitbar.author.github>
# <bitbar.desc>Displays Docker count statistics (not container metrics)</bitbar.desc>
# <bitbar.image></bitbar.image>
# <bitbar.dependencies></bitbar.dependencies>
# <bitbar.abouturl></bitbar.abouturl>
PATH=/usr/local/bin:$PATH
stopRemoveAll() {
docker ps -aq | xargs docker stop -t 1 | xargs docker rm
}
forcePruneVolume() {
docker volume prune -f
}
forcePruneSystem() {
docker system prune -f
}
forcePruneImage() {
docker image prune -f
}
forcePruneNetwork() {
docker network prune -f
}
nuke() {
stopRemoveAll
forcePruneVolume
forcePruneNetwork
forcePruneSystem
}
case "$1" in
stopRemoveAll)
stopRemoveAll;;
forcePruneVolume)
forcePruneVolume;;
forcePruneSystem)
forcePruneSystem;;
forcePruneImage)
forcePruneImage;;
forcePruneNetwork)
forcePruneNetwork;;
nuke)
nuke;;
esac
CNT_RUNNING=$(docker ps -q | wc -l | tr -d ' ')
CNT_TOTAL=$(docker ps -qa | wc -l | tr -d ' ')
CNT_VOLUMES=$(docker volume ls -q | wc -l | tr -d ' ')
CNT_IMAGES=$(docker images -q | wc -l | tr -d ' ')
CNT_NETWORKS=$(docker network ls -q | wc -l | tr -d ' ')
CNT_NETWORKS=$((CNT_NETWORKS - 3))
echo "D: ${CNT_RUNNING}/${CNT_TOTAL} | size=12"
echo "---"
echo "Running: ${CNT_RUNNING}"
echo "Total: ${CNT_TOTAL}"
echo "Volumes: ${CNT_VOLUMES}"
echo "Images: ${CNT_IMAGES}"
echo "Networks: ${CNT_NETWORKS}"
echo "---"
echo "Stop & Remove All Containers | bash='$0' param1=stopRemoveAll terminal=false"
echo "Force Prune: Volume | bash='$0' param1=forcePruneVolume terminal=false"
echo "Force Prune: System | bash='$0' param1=forcePruneSystem terminal=false"
echo "Force Prune: Images | bash='$0' param1=forcePruneImage terminal=false"
echo "Force Prune: Networks | bash='$0' param1=forcePruneNetwork terminal=false"
echo "---"
echo "Nuke: Containers, Volumes, Networks, System | bash='$0' param1=nuke terminal=false"
echo "---"
echo "Refresh Stats | terminal=false refresh=true"
#!/bin/bash
# <bitbar.title>IP Address Info</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Jack Higgins</bitbar.author>
# <bitbar.author.github>skhg</bitbar.author.github>
# <bitbar.desc>Displays your local IP address with useful extra info</bitbar.desc>
# <bitbar.image>https://raw.githubusercontent.com/skhg/BitBar-Plugins/master/NetworkInfo/ip_info.jpg</bitbar.image>
# <bitbar.dependencies></bitbar.dependencies>
# <bitbar.abouturl>https://github.com/skhg/BitBar-Plugins/tree/master/NetworkInfo</bitbar.abouturl>
LOCAL_IP=$(ipconfig getifaddr en0 2>&1)
LOCAL_OK=$?
if [ $LOCAL_OK != 0 ] ; then
LOCAL_PART="❌"
else
LOCAL_PART=$LOCAL_IP
fi
# REMOTE_IP=$(dig +short myip.opendns.com @resolver1.opendns.com 2>&1)
REMOTE_IP=$(curl -s "ipinfo.io/ip")
REMOTE_OK=$?
if [ $REMOTE_OK != 0 ] ; then
REMOTE_PART="❌"
else
REMOTE_PART="$REMOTE_IP"
fi
# echo "$LOCAL_PART | size=12"
echo "$REMOTE_IP | size=12"
echo "---"
echo "Local: $LOCAL_PART"
echo "WAN: $REMOTE_PART"
#!/bin/bash
# <bitbar.title>Refresh Me</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Karl Piper</bitbar.author>
# <bitbar.author.github>KarlPiper</bitbar.author.github>
# <bitbar.desc>How to refresh just one plugin, or restart BitBar entirely.</bitbar.desc>
# <bitbar.image>https://raw.githubusercontent.com/KarlPiper/Plugins-for-Bitbar/master/images/refresh.png</bitbar.image>
# <bitbar.dependencies>bash</bitbar.dependencies>
if [[ "$1" = "restart" ]]; then
osascript <<EOD
tell application "BitBar" to quit
delay 1
tell application "BitBar" to activate
EOD
fi
echo "↻"
echo "---"
echo "Refresh Me| terminal=false refresh=true"
echo "Restart Bitbar| bash='$0' param1=restart terminal=false";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment