BitBar – OSX custom menu bar – running #!/bin/bash

bitbar-menuFix the frustration of needing quick access bash tools in the Finder.

BitBar allows for simple creation of bash based plugins, resulting in a custom menu bar.

My current usage:
1: Show / Hide – all desktop items, including selection from menu & color coding
2: Current LAN / WAN IP address
3: Quick URLs to http, smb, afp resources.

Getting up and running.

1: Download and install BitBar, setup to launch at login in SystemPrefs
2: On first run – setup your “plungin directory” – mine is a subfolder within my scripts path
3: Download the sample plugin scripts from GitHub to see samples
4: Modify to your needs.

Some IMPORTANT notes about the plugin scripts:

1: Each script is its own menu in the menu bar.
2: [echo “—“] establishes a divider in the menu
3: Lines above the FIRST [echo “—“] are rotated in the menu bar, below are not
4: Selectable menu items are URLs and Bash scripts you call
5: Time interval between runs of the plugin script is part of the filename

My current plugin script:
#!/bin/bash

# ON/OFF
# BitBar plugin
#

STATUS=`defaults read com.apple.finder CreateDesktop`

# Line 1 - Menu Title Bar
if [ $STATUS = "true" ]; then
  echo "ƒ (d) | color=green"
else
  echo "ƒ (d) | color=red"
fi

echo "---"

# Line 2 - Choice Toggle Selection
echo "HIDE / SHOW Desktop Items: | color=white"
if [ $STATUS = "true" ]; then
  echo "All Desktop items are being displayed"
  echo "Select HIDE to hide all desktop items"
  echo "HIDE Desktop | color=red terminal=false bash=~/Scripts/desktop/desktop-files-hide.sh"
else
  echo "All Desktop items are hidden"
  echo "Select SHOW to show all desktop items"
  echo "SHOW Desktop | color=green terminal=false bash=~/Scripts/desktop/desktop-files-show.sh"
fi

echo "---"


# Line 3 - Current IP Address Infomation

echo "Current IP address info: | color=white"
echo "LAN: " `ipconfig getifaddr en0`
echo "WAN: " ` curl -s ipecho.net/plain; echo`

echo "---"



# Line 4 - quick connect URLs

echo "Quick Connect URLs: | color=white"
echo "My Website | href=http://my.website.com | color=pink"
echo "Video Library | href=afp://MEDIA.local/VIDEO_LIBRARY/ | color=pink"
echo "Photo Backup | href=smb://192.168.3.133/PHOTOBAK/ | color=pink"
echo "Transfer Inbox | href=afp://DEB.local/TRANSFER/inbox/ | color=pink"
echo "Transfer Outbox | href=afp://DEB.local/TRANSFER/outbox/ | color=pink"
SCRIPTS WHICH ARE CALLED BY ABOVE PLUGIN SCRIPT:
#!/bin/bash
#
# HIDE ALL FINDER ITEMS
#
defaults write com.apple.finder CreateDesktop false; killall Finder
#!/bin/bash
#
# SHOW ALL FINDER ITEMS
#
defaults write com.apple.finder CreateDesktop true; killall Finder

 

SOURCES:
#########################################################
# Source on GitHub:                                     #
# https://github.com/matryer/bitbar#writing-a-plugin    #
#########################################################