Last active
October 10, 2015 23:28
-
-
Save ebith/3767494 to your computer and use it in GitHub Desktop.
KeePass2のデータベースをターミナルから検索してクリップボードにコピーする
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 perl | |
use strict; | |
use warnings; | |
use utf8; | |
use File::KeePass; | |
use IO::Prompter; | |
use Encode; | |
my $file = shift @ARGV; | |
my $pass = prompt('Password: ', -e => ''); | |
my $k = File::KeePass->new; | |
$k->load_db($file, $pass); | |
$k->unlock; | |
my @entries = $k->find_entries({}); | |
open(OUT, '| peco --initial-matcher Migemo | awk \'BEGIN { FS = " :: "} { printf $2 }\' | pbcopy '); | |
foreach my $entry (@entries) { | |
next unless ($entry->{password}); | |
print OUT encode_utf8("$entry->{title} : $entry->{username} :: $entry->{password}\n"); | |
} | |
close(OUT); | |
$k->clear; | |
__END__ | |
curl -L https://cpanmin.us | perl - --sudo App::cpanminus | |
cpanm --sudo File::KeePass IO::Prompter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment