Last active
August 13, 2019 06:28
-
-
Save wrtsprt/90f559e06df0b963ec4d3a28ba698075 to your computer and use it in GitHub Desktop.
Template for a ruby BitBar plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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