Skip to content

Commit

Permalink
Feature/keybase plugin (#675)
Browse files Browse the repository at this point in the history
* Add Keybase plugin v0.1

* Update desc.
  • Loading branch information
hSATAC authored and tresni committed Jan 24, 2017
1 parent a87dc24 commit 6324571
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Tools/Keybase/keybase-encrypt.10m.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env LC_ALL=en_US.UTF-8 ruby

# <bitbar.title>Keybase Encrypt/Decrypt</bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author>Ash Wu(hSATAC), Aaron Huang(aar0ntw)</bitbar.author>
# <bitbar.author.github>pan-cat</bitbar.author.github>
# <bitbar.desc>A helper for keybase encryption and decryption. Simply copy content you want to decrypt/encrypt and click action, the result will be copied into your clipboard.</bitbar.desc>
# <bitbar.image>http://ash.cat/2FT8+</bitbar.image>
# <bitbar.dependencies>ruby,keybase</bitbar.dependencies>

#--- User parameters ----------------------------------------------------------
KEYBASE = "/usr/local/bin/keybase"

#--- Script internals ---------------------------------------------------------
# TODO: Handle keybase cli error with color or icon?

REFRESH = "---\nRefresh | refresh=true"

# decrypt
if ARGV[0] == "decrypt"
`/usr/bin/pbpaste | #{KEYBASE} decrypt | /usr/bin/pbcopy`
exit
end

# ecrypt
if ARGV[0] == "encrypt"
target = ARGV[1]
`/usr/bin/pbpaste | #{KEYBASE} encrypt #{target} | /usr/bin/pbcopy`
exit
end


icon = "🔑"


following = `#{KEYBASE} list-following`.split("\n").map{|f|
"--#{f} | bash=#{__FILE__} param1=encrypt param2=#{f} terminal=false"
}.join("\n")


puts """
#{icon}
---
Encrypt
#{following}
---
Decrypt | bash='#{__FILE__}' param1=decrypt terminal=false
---
#{REFRESH}
"""

0 comments on commit 6324571

Please sign in to comment.