about summary refs log tree commit diff
path: root/xlocate
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-01-03 18:47:25 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2016-01-03 18:47:25 +0100
commit6f6f0e9104092c745600725ecdd7da6c7e258c50 (patch)
tree5a4457c6a6e731f24545a0d2eb21267df847d8f2 /xlocate
parent16529ff2fba610212b3e2dce225fb7248dcdca90 (diff)
downloadxtools-6f6f0e9104092c745600725ecdd7da6c7e258c50.tar.gz
xtools-6f6f0e9104092c745600725ecdd7da6c7e258c50.tar.xz
xtools-6f6f0e9104092c745600725ecdd7da6c7e258c50.zip
xlocate: add progress bar and fix for newer findutils which need / first.
Diffstat (limited to 'xlocate')
-rwxr-xr-xxlocate10
1 files changed, 8 insertions, 2 deletions
diff --git a/xlocate b/xlocate
index 85513a8..472045f 100755
--- a/xlocate
+++ b/xlocate
@@ -4,9 +4,15 @@
 : ${XLOCATE_DB:=~/.cache/xlocate.db}
 
 xupdatedb() {
+	if command -v pv >/dev/null; then
+		PROGRESS="pv -l"
+	else
+		PROGRESS=cat
+	fi
 	echo "xlocate: reindexing database..." 1>&2
 	xbps-query -Ro '*' |
-		sed 's/ *([^)]*)$//; s|: ||;' |
+		$PROGRESS |
+		sed 's/ *([^)]*)$//; s|: ||; s,^,/,' |
 		/usr/libexec/frcode >"$XLOCATE_DB"
 }
 
@@ -26,7 +32,7 @@ if [ -e "$XLOCATE_DB" ]; then
 	esac
 	# XXX also matches template in package name.
 	glocate $rx -d "$XLOCATE_DB" "$1" |
-		sed 's|^\([^/]*\)-[^-/]*/|\1\t/|'
+		sed 's|^/\([^/]*\)-[^-/]*/|\1\t/|'
 else
 	xbps-query --regex -Ro "$@" |
 		sed 's/ *([^)]*)$//; s/^\([^ ]*\)-[^-]*: /\1\t/'