Skip to content

Instantly share code, notes, and snippets.

@0mark
Last active December 21, 2015 08:49
Show Gist options
  • Save 0mark/6281084 to your computer and use it in GitHub Desktop.
Save 0mark/6281084 to your computer and use it in GitHub Desktop.
Pacman thing
#!/usr/bin/perl
use strict;
if (not -e "pkglist") {
exec("pacman -Qqet > pkglist");
}
my $param=shift();
my @keep=split(/\n/,`cat pkglist | grep -v '^#'`);
my @try=split(/\n/,`pacman -Qqet`);
my $out="";
foreach (@try) {
my $in=1;
my $x=$_;
$in=grep($x eq $_, @keep);
$out.=$_." " if ($in==0);
}
if ($param eq "new") {
open (FILE, '>>pkglist');
$out =~ s/ /\n/g;
print FILE "---- NEW ----\n$out";
close (FILE);
} elsif ($param eq "do") {
system("sudo pacman -Rns $out");
exec('sudo pacman -Rsn $(pacman -Qdtq)');
} else {
print "$out\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment