Fortune

Image preview of Fortune plugin.

fortune.5m.sh

Edit
Open on GitHub
#!/usr/bin/env bash

# <xbar.title>Fortune</xbar.title>
# <xbar.version>v1.0</xbar.version>
# <xbar.author>Volker Wieban</xbar.author>
# <xbar.author.github>hpcodecraft</xbar.author.github>
# <xbar.desc>Shows a random fortune quote</xbar.desc>
# <xbar.image>https://cloud.githubusercontent.com/assets/1476865/24081772/fd2011c2-0cb9-11e7-8679-30f1c56c0acd.png</xbar.image>
# <xbar.dependencies>bash,fortune</xbar.dependencies>

cookie="iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3BpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo1NjIwYjM2NS0wZGZhLTQ0NjYtOGMyMi1lOGJhNzZjY2Q0Mm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rp87UO2Fye4DU1AKuCrAOItBtkOU0RK9dnyvs4VYmFtwOvToea8680OZNL5tT0x83tXt/0Y3zH6Vst4BZTYeXu8XjI1u4q6ERftJ7G4wQgXM/BYQmURUdiWyXv+l8G8/vlFnTWVOtucvP9dpnJFkia0auMge6Oh6ubmhdpzn+Rd1XQcjhufqeaeHCuCgYstUJhsI7wETDyA6P425raLR+PgnX7WYYyP+ngam1FcMNctiwfkCDh1/abdMQRBQXl7+BVV9kDNtHk1RqZrgweRTsDIxwPcMBVchxkVUkNuDzz51WBCefg1Gjo6MsoTZCIFolOBvjSORSGx5ebmX47gIV9rUF0wmAookqoKr0oAhBmE6fbCqj2H/6QtoK3QLpLwbJmFhSZMAzb0Sk5F1mJAUFeHVR78mEonjdt5hUUCwH7z/ppSOLHWQVLxRKC4B76QpM1Fatht880kQz36YqgJk40BuEwyXwUQwi6llDVvBGw8MQ/fb7fwuU4MOOtN66Ohiddep4dByCNFQGtKmDEJdggRlE74FS1yCJa8D+QQ1FbUSSyCwBm4MD0GKrIw019aAlRPgslvglCT9q9LMLI+bn759VQvcOlvZ0omSqgLqRGo7wQHGTR1DvWvR/ulSEjYbcOmzMdyZjYd+mppvJJqKXC4Hi7Lb2VzESs0AnmJIooGxj8//zK8HBry+OrhLvCgotMMm0EP7YKgG5M044mIW384klXeHvjx48HDPihINg+zY96+ggMHdMkAE3J0IYvXOlQ/t4XtDrCTBXUQH3SaAGHmk01sQNQa5mu6rvp5T504Pvqqk1qm3mceXwx6gjYMu53H/7gw0ysZhZYqjD355PbUY8Oty2qPbCiWbr2VGqGm+0th1YiUZWUPvkWN7i4qW+jjg/31j/ynAAKk7+eVEqimNAAAAAElFTkSuQmCC"

fortune="/usr/local/bin/fortune"

echo "|dropdown=false image=$cookie"
echo "---"

if [[ -x $fortune ]]; then
  echo "Next cookie|refresh=true image=$cookie"
  echo "---"
  echo " |trim=false"
  $fortune|/usr/bin/sed 's/-/–/g; s/^/    /; s/$/  |font=Avenir size=14 trim=false/'
  echo " |trim=false"
else
  echo "Fortune is not installed|color=red"
  echo "|trim=false"
  echo "Please install it via Homebrew using this command"
  echo "brew install fortune|font=Courier color=green"
  echo "Then refresh your Bitbar (Preferences ▶ Refresh all)"
fi