Skip to content

Instantly share code, notes, and snippets.

@wrtsprt
Last active August 13, 2019 06:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrtsprt/90f559e06df0b963ec4d3a28ba698075 to your computer and use it in GitHub Desktop.
Save wrtsprt/90f559e06df0b963ec4d3a28ba698075 to your computer and use it in GitHub Desktop.
Template for a ruby BitBar plugin
#!/usr/bin/env /Users/<myusernamehere>/.rbenv/shims/ruby
#
# <bitbar.title></bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author></bitbar.author>
# <bitbar.author.github></bitbar.author.github>
# <bitbar.desc></bitbar.desc>
# <bitbar.dependencies></bitbar.dependencies>
# <bitbar.abouturl></bitbar.abouturl>
require 'net/http'
require 'json'
require 'open-uri'
def i_can_haz_internet?
true if open('https://google.com')
rescue
false
end
def api_token
output = `security find-generic-password -l <myservicenamehere> -w`
raise 'api token not setup in keychain' if output =~ /The specified item could not be found in the keychain/
output.chomp
end
if i_can_haz_internet?
puts 'BitBaRB'
puts '---'
puts 'Refresh this plugin| refresh=true'
puts 'Edit this plugin | bash=<editorofchoice ie code> param1=--add param2=/Users/<pathtothisfile> terminal=true'
else
puts '⏳'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment