Skip to content

Instantly share code, notes, and snippets.

@adamwiggins
Created February 8, 2009 00:39
Show Gist options
  • Save adamwiggins/60122 to your computer and use it in GitHub Desktop.
Save adamwiggins/60122 to your computer and use it in GitHub Desktop.
#!/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