adamwiggins (owner)

Revisions

gist: 60122 Download_button fork
public
Public Clone URL: git://gist.github.com/60122.git
Embed All Files: show embed
gpger.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/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