about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README1
-rwxr-xr-xxpkg30
2 files changed, 31 insertions, 0 deletions
diff --git a/README b/README
index e0bdfe3..ed21973 100644
--- a/README
+++ b/README
@@ -28,6 +28,7 @@ https://github.com/voidlinux/xbps
   xnew PKG - create XBPS template template
   xnodev - list not installed -devel packages for installed packages
   xoptdiff [-q] [PKGS...] - show template options which differ from binary package
+  xpkg [-RamOHvV] - convenient package lister
   xpstree - display tree view of xbps-src processes
   xq [-R] PKGS... - query information about XBPS package
   xrecent [REPOURL|XBPS_ARCH] - list packages in repo ordered by build date
diff --git a/xpkg b/xpkg
new file mode 100755
index 0000000..40e6ed1
--- /dev/null
+++ b/xpkg
@@ -0,0 +1,30 @@
+#!/bin/sh
+# xpkg [-RamOHvV] - convenient package lister
+
+flags=
+filter0='/^.[^i*].\? /d'
+filter1='s/^...\? //'
+filter2='s/-[^- ]* .*//'
+mode="--search="
+
+while getopts R:vVmOHa flag; do
+	case "$flag" in
+		R) flags="$flags -i --repository=$OPTARG";;
+		m|O|H) mode="-$flag"; filter0=; filter1=; filter2='s/-[^-]*$//';;
+		a) flags="$flags -R"; filter0=;;
+		v) filter2='s/ .*//';;
+		V) filter2=;;
+		?) printf "Usage: %s [-RamOHvV]
+  -R REPO  consider only packages from REPO
+  -a       list all packages (default: only installed)
+  -m	   list manual packages
+  -O       list orphaned packages
+  -H       list packages on hold
+  -v       show version numbers
+  -V       show version numbers and description
+" $0 1>&2
+		exit 1;;
+	esac
+done
+
+xbps-query $flags $mode | sed "$filter0;$filter1;$filter2"