Skip to content
Thoughtful, detailed coverage of everything Apple for 30 years
and the TidBITS Content Network for Apple professionals
16 comments

BitBar Lets You Put Anything in Your Mac’s Menu Bar

There are all sorts of apps that add various capabilities to your Mac’s menu bar, but I’ve stumbled across one that can add literally anything to the menu bar through a plug-in system. It’s called BitBar, and it’s both free and open source. I’ve tested and confirmed that it works in both macOS 10.14 Mojave and 10.15 Catalina.

When you first launch BitBar, it asks you to choose a directory to store plug-ins. I made a BitBar folder on my iCloud Drive so I can easily sync plug-ins between machines. That works well, and I presume Dropbox or Google Drive would work similarly.

The BitBar Web site contains a rich library of community-created plug-ins. There are plug-ins for displaying weather, stock prices, cryptocurrency prices, email messages, Slack notifications, and pretty much anything you can think of, such as whether your cat is in or out. Installing a plug-in is as easy as clicking the Add to BitBar button on a plug-in’s library page, which installs the plug-in into your specified plug-in folder.

The Add to BitBar button in context.

All BitBar plug-ins are simple text-based shell scripts. Removing one is as simple as moving it out of your plug-in folder, Control-clicking BitBar in the menu bar, and choosing Preferences > Refresh All (I disable plug-ins by putting them in an Archive folder in my plug-in folder). Likewise, you can drag any shell script you want into the plug-in folder and refresh to make it available. You can quickly get to your plug-in folder by Control-clicking BitBar and choosing Preferences > Open Plugin Folder.

The beauty of BitBar is that any script that works in Terminal can be a BitBar plug-in. It could be a simple shell script, a Python script, a Ruby script, or even an AppleScript if you put the right hooks in. It also means that you can easily modify all the available plug-ins in any text editor, and you may be able to figure out how to make small changes just by following the script’s example, even if you don’t know the scripting language well. In fact, that’s a common situation.

Modifying BitBar Plug-ins to Get What You Want

Imagine that you find a plug-in that does kind of what you want, but not quite. The good news is that it’s easy to modify a plug-in.

For instance, I took the Got Internet? plug-in, changed its ping_address variable from 8.8.8.8 (Google DNS) to tidbits.com, and changed the display text so that it shows “TidBITS 👍” when our Web site is reachable and “TidBITS 👎” when it’s not.

Here’s a little hack you might find useful. Install the Simple RSS Reader plug-in, open up its file, and change the FEED_URL variable, which is by default http://feedpress.me/sixcolors?type=xml, to https://tidbits.com/feed/. You can now access all the latest TidBITS articles from your menu bar!

BitBar showing the latest TidBITS headlines.

I also tweaked the Coinbase Prices plug-in. It shows a bunch of different cryptocurrencies by default, but not the one I mostly care about: Chainlink. So I simply copied the dash_price line of code, pasted it at the end of the block, renamed it to link_price and changed DASH-USD in the Coinbase URL to LINK-USD. Finally, I added an echo $link_price line at the end. This was just monkey scripting—the script is in Python, which I don’t know well, and my changes worked just fine, aside from not showing a fancy icon on the side of the price.

Code modified in the Coinbase Prices plug-in to show LINK.

The plug-in that I’ve modified the most heavily—and the one that actually led me to BitBar—is mpd-control. After getting fed up with iTunes/Music messing up my music library, I’ve been experimenting with the command-line-based mpd music daemon, which has a number of front ends. I like the Terminal-based ncmpcpp, but it’s awkward having to switch to a Terminal window to pause my music. The mpd-control plug-in, by default, shows the currently playing track and clicking it plays or pauses the music. It was simple enough to change it so that I have a menu of commands that let me play/pause, move to the next or previous track, and open ncmpcpp in a Terminal window.

The mpd-control plug-in modified to do what I want.

If you’re not as nerdy as I am, there’s also a nice iTunes Now Playing plug-in to control your music from the menu bar.

For an extreme example, I brought in a menu bar script I use in Linux to see the weather forecast. Amazingly, it worked pretty much out of the box. I modified it to add an option to open Terminal and curl wttr.in, which brings up a console-based weather forecast.

wttr.io in a Terminal window.

Creating Plug-ins in BitBar

Let me show you how easy it is to create a BitBar plug-in. If you don’t know any shell scripting, this is a great way to learn, since you can easily integrate your shell scripts with the native macOS interface without much risk. And if you don’t want to learn, you could sweet-talk or pay someone to create the plug-in you need.

You don’t have to start from scratch. The BitBar documentation includes several top-to-bottom examples, and the plug-in gallery even has tutorial plug-ins illustrating different concepts that you can modify to your heart’s content. But let me show you how I created a plug-in from scratch to demonstrate how simple it can be.

Open Terminal in /Applications/Utilities. Don’t worry, we’re not doing anything scary. Type date and press Return. You get the current date and time.

Output of "date" in the Terminal.

You can easily put that into BitBar. I opened BBEdit and made this simple script called date.sh.

#!/bin/bash
date

The first line, #!/bin/bash, tells the system that it’s a script. Once you make that text file executable, macOS will recognize it as a program (see below for instructions) and execute any Terminal commands that follow the first line. The next line simply invokes the date command. In other words, typing date in Terminal shows you the current date and time, and if you put that command in a BitBar script, it will do the same thing.

Making a script file executable can be a little intimidating if you’re not used to the Terminal, but it’s not hard. You have to do this so it can be run as a program.

  1. Open Terminal.
  2. Open the BitBar plug-in folder in Finder.
  3. In the Terminal, type chmod +x  (including the trailing space) to make the script executable.
  4. Drag the date.sh icon from the the Finder window into Terminal, which inserts its directory path.
  5. Press Return.

Refresh BitBar, and you now have a date and time display.

A simple "date" plug-in in BitBar.

If you type man date in Terminal to see the manual pages for the date command, you’ll see examples of how you can customize the output. Feel free to play around with it.

But what if we want to make it so clicking the date opens the Calendar app? That’s easy to do, but it takes some jiggering. There are special formatting hooks you can add to a script to add BitBar actions, listed on BitBar’s GitHub page. But they work only in the context of an echo command, which is a simple Unix command to display text or the value of a variable in Terminal.

So first, I changed the script to assign the output of the date command to a MYDATE variable, like so: MYDATE=$(date) (note there are no spaces around the equals sign!). Don’t let the symbols intimidate you—you’re just creating a variable called MYDATE. The dollar sign and parentheses tell the system to assign the output of the date command to that variable.

Next, I created a line that tells BitBar to display the date and make it clickable. If I were to write just echo $MYDATE, it would show only the contents of the MYDATE variable—no different than before. But I then added the special BitBar hooks, so it looks like this:

echo "$MYDATE | href=file:///Applications/Calendar.app"

First, it echoes the MYDATE variable. (Note that in shell scripting, you refer to a variable by putting a dollar sign ($) in front of the variable name.) Inside the quotes, I put not only that MYDATE variable but also the BitBar-specific commands, delimited by the pipe symbol. If you are familiar with HTML, you’ll recognize the href command, which specifies a link. I use that to create a link to the Calendar app.

After a refresh, I could click the date to open the Calendar app. The full script looks like this:

#!/bin/bash

MYDATE=$(date)
echo "$MYDATE | href=file:///Applications/Calendar.app"

But what if you want a menu of commands? You can accomplish that by adding echo "---" anywhere in the BitBar plug-in script. However, with the way the plug-in is set up now, I won’t see the menu because it opens Calendar whenever I click it. So I need to change it back to make it not clickable:

#!/bin/bash

date
echo "---"

But what commands should we put in our menu? Let’s make a clickable link to the Calendar app, like this:

echo "Calendar | href=file:///Applications/Calendar.app"

All I’m doing here is echoing the word “Calendar” and using the code from the previous example to make it open the Calendar app when clicked.

So our final plug-in script looks like this and shows the date as a menu from which you can open the Calendar app:

#!/bin/bash

date
echo "---"
echo "Calendar | href=file:///Applications/Calendar.app"

You might notice that the time it reports is slightly off. By default, each BitBar plug-in refreshes once every minute. You can change this by simply adding a timestamp to the filename, like this: date.1s.sh. Change that to date.1h.sh to refresh every hour or date.1d.sh to refresh once per day. Check the BitBar documentation for more info.

You can take this basic example and expand it in a few ways:

  • Change the date format
  • Open other calendar apps like Fantastical or BusyCal
  • Create a shortcut to the Date & Time preference pane

Making a Bookmarks Plug-in

I often switch between Web browsers, and I get tired of trying to keep my bookmarks in sync. I could use Alco Blom’s URL Manager Pro, but in the interests of rolling my own, I’ve been thinking that a good solution would be a simple text file with one URL per line. Text editors like BBEdit usually let you easily follow URLs in text files (in BBEdit, Command-click a URL to open it in your default browser). While playing with BitBar, I thought: “Wait, maybe I could turn a list of links into a plug-in.” It turned out to be pretty easy, though I’m still working on perfecting it.

My first plug-in along these lines was extremely basic. I created a list of URLs and saved it in ~/Documents/urls.txt. (If you want to follow along, you can name it whatever you want and store it wherever you want.)

I then structured the script like so:

#!/bin/bash # Tell the system this is a script

LINKFILE=~/Documents/urls.txt
# Create a variable called LINKFILE that points to my URL list,
# which is cleaner than referring to the list directly in the code.

echo "URLs"
echo "---"

These two lines tell BitBar to make “URLs” the display name and echo --- indicates a submenu.

Here’s where things get interesting. We’re going to bring in our URL list and echo each line along with the command that tells BitBar it’s a link.

while read line; do
    echo "$line|href=$line"
done <$LINKFILE

The key part is at the end, <$LINKFILE, which tells the shell to import every line of that file into the while loop. while read line translates to “While this file has a line I have not processed, read the line in and store it in variable line.” And do just means do. While there are lines to process, it will echo that line, $line, along with the pipe character and href=, which tells BitBar that the following text is a link. The second $line simply tells BitBar to link the title $line to the URL $line. In this case, the link title and link URL are identical.

In practice, it looks like this:

A simple bookmarks plug-in with raw URLs.

That works, but I’d rather have descriptive names instead of raw URLs. Also, I have a lot of bookmarks and only so much screen real estate. So I tried my hand at creating a Markdown-based bookmark file that would contain descriptive names and a menu hierarchy. Such text processing necessitated using regular expressions, and the simplest way to do that in a shell script is the sed command, with which I’m not very familiar. So I Googled enough sed commands to make it sort of work:

#!/bin/bash

LINKFILE=~/Documents/SyncThing/links.md

echo "Bookmarks"
echo "---"

while read line; do
    [ -z "$line" ] && continue
    LINKNAME=`echo $line | sed 's/^.*\[//;s/\].*$//'`
    LINK=`echo $line | sed 's/^.*(//;s/).*$//'`
    echo "$LINKNAME|href=$LINK"
done <$LINKFILE

The above code isn’t that different from the first bookmark script. It cycles through a list of links, only in Markdown this time, and in each line it uses sed to extract either the title or the URL and add it to a variable. It then echoes the LINKNAME variable and tells BitBar to link it to the URL stored in LINKURL. The [ -z "$line" ] && continue line at the top of the while loop tells the shell to skip blank lines.

Note the backticks (`) around the commands assigned to LINKNAME and LINK. They tell macOS to assign the results of the commands to the variable instead of just the text.

I have one problem with this setup. The way BitBar does sub-menus is weird. In Markdown, headings work like this:

#Bookmarks
[TidBITS](https://tidbits.com/)
[TidBITS Talk](https://talk.tidbits.com/)
[The Prepared](https://theprepared.com/)

##News
[Slashdot](https://slashdot.org/)

A single # indicates a top-level header, ## is a subhead, and so on. However, to get it to work with BitBar, I have to format my Markdown URL list like this:

[TidBITS](https://tidbits.com/)
[TidBITS Talk](https://talk.tidbits.com/)
[The Prepared](https://theprepared.com/)

News
[--Slashdot](https://slashdot.org/)

So the subfolder name is “News,” and to indicate that an item goes into that subfolder, I have to put two dashes in front of the line. I’m sure it’s possible to create a script to count the number of lines under a Markdown header, strip away the # characters, and insert -- in front of each line under the header, but I don’t know sed and awk that well. (If you do, let me know, and you’ll earn my eternal regular expression appreciation.)

However, the result in BitBar is nice and tidy, and choosing one of these bookmarks from the menu opens it in my default Web browser. When I switch browsers, all I have to do is change which one is the default to make my bookmarks work with the new one instead.

The Markdown bookmark plug-in in action.

BitBar Can Be Anything You Want

I hope I’ve given you a good idea of some of the things you can do with BitBar, even if you’re not super comfortable with the Terminal or scripting. If you’ve ever thought, “I wish I could put that in my menu bar,” there is probably a way to do it with BitBar. You’re limited only by your imagination and what you or someone you know can do in a shell script.

If you want to download the BitBar plug-ins I’m using, creating, and editing, you can find them on my GitHub page.

Subscribe today so you don’t miss any TidBITS articles!

Every week you’ll get tech tips, in-depth reviews, and insightful news analysis for discerning Apple users. For 29 years, we’ve published professional, member-supported tech journalism that makes you smarter.

Registration confirmation will be emailed to you.

Comments About BitBar Lets You Put Anything in Your Mac’s Menu Bar

Notable Replies

  1. BitBar is nice, but as far as I can tell, it’s no longer being developed.

    A newer alternative is TextBar which does similar things, and the developer has been very open to ideas and suggestions.

    It is definitely nice to be able to output shell commands to your menu bar. I have one which shows me a better indication of Time Machine’s status and progress, my git repos, and various bits of system information including the SSID that I am connected to and whether or not my VPN is active.

  2. I looked at BitBar’s GitHub. The last commit was a year ago and the developer is still responding to concerns, so I don’t think it’s dead, just not frequently updated. I’ll check out TextBar, but I like the fact that BitBar is open source.

  3. It sounds like an interesting idea, but I am leery of having an app that adds yet more stuff to my menubar. I use Bartender, but I still have a lot of items up there. What would be useful is a menubar dropdown for apps that are in the menu bar. I could group my items into discreet groups and call on them as I need them. I have something in the recesses of my mind that is telling me Butler can do that. I’ll have to check.

  4. Both of these sound like fun. Will check them out.

  5. Type: curl wttr.io should be curl wttr.in (r not o).

    I had recently found this so recognized the error.

    While we’re on the subject you add cities, airport codes and zip codes curl wttr.in/lax and curl wttr.in/newyork for example.

    BTW I aliased it to wea.

  6. "I am looking for a Swift developer who lost their job because of the pandemic. BitBar is too good to go stale, and I don’t have the time to learn Swift and rebuild the project.

    If you can recommend somebody, please tweet me @matryer.

    Let’s see if we can breathe some life into this project."

    I installed using brew and the app was last updated in 2016. Maybe he has later versions but he is falling behind.

    Thanks for the post, was interesting. I may have menu bar room on my 27" iMac but not my 15" MBP.

  7. My favourite date command: date ‘+%F %H:%M’ This is the format I name files that I want to sort by Year-Month-Day and Time. Soon in Bitbar here.

  8. Out of the menu bar option, how does it compare to the old faithful Platypus ?

  9. Check out Custom Menu 3 here.

  10. Ack, thanks! I’ve fixed that. You can also do curl v2.wttr.in for some fancy graphs, and there is a “man page” of sorts.

  11. I’m hoping the extra attention might give the project a boost. In any case it’s free to use and still works.

  12. @Apple2_Plus thank you for the reference to Custom Menu 3. I went to the App Store and bought it. Now I’m learning how best to use it. A little ruff edges but they are mine, not the app’s lol. Good addition.

  13. I’ve been using MKConsole for years to show my latest system log file output on my desktop. It’s very simple and it does well what it’s supposed to. Despite being so old it still receives updates by the dev, like 64 bit for Catalina. :slight_smile:

  14. Thanks, @jcenters, for the heads up about BitBar! I haven’t written any code in years, but your post motivated me to try to write a bash/awk script to put the weather forecast in my menu bar. I saw you had such a script for Linux (which I don’t use) and I got a few ideas from there and then went my own way, basing my script on Open Weather Map’s API, which is free. I wasn’t ever an awk coder, but I pick up languages easily and it’s been fun to learn. It’s still a work in progress.

Join the discussion in the TidBITS Discourse forum

Participants