Created
February 8, 2009 00:39
-
-
Save adamwiggins/60122 to your computer and use it in GitHub Desktop.
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/ruby | |
# change these to your liking | |
user = "mygpguser" | |
encrypted = "/path/to/file.gpg" | |
########## | |
require 'fileutils' | |
work = "#{encrypted}_tmp" | |
cmd, *args = ARGV | |
args = args.join(' ') | |
if cmd == 'all' | |
system "gpg --decrypt #{encrypted}" | |
elsif cmd == 'search' and args.strip != '' | |
system "gpg --decrypt #{encrypted} | grep '#{args}'" | |
elsif cmd == 'edit' | |
begin | |
system "gpg --decrypt #{encrypted} > #{work}" | |
system "vi #{work}" | |
system "mv #{encrypted} #{encrypted}.bak" | |
system "gpg -r #{user} --encrypt -o #{encrypted} #{work}" | |
ensure | |
FileUtils.rm_f(work) | |
end | |
else | |
puts "usage: acc all" | |
puts " acc search <keywords>" | |
puts " acc edit" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment