From 344b8ee9a108203b02e9a2280ce5d3393861a4d6 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Wed, 28 Feb 2018 15:16:07 +0200
Subject: [PATCH] Rewrote prune_prerun (prune prerun files used to time shell
 commands) because grep on OpenBSD doesn't have support for null-terminated
 strings.

---
 .bashrc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/.bashrc b/.bashrc
index 1589149..8b97042 100644
--- a/.bashrc
+++ b/.bashrc
@@ -83,7 +83,6 @@ alias unssh="ssh -o \"UserKnownHostsFile /dev/null\" -o \"StrictHostKeyChecking
 alias todo="vim \$HOME/Documents/TODO.yml"
 alias sudo="sudo "
 alias presentation='docker dev adarnimrod/presentation'
-alias prune_prerun='find "$HOME" -maxdepth 1 -name ".prerun.*" -print0 | grep -zv "$(pgrep -u "$(id -u)" bash)" | xargs -0r rm '
 alias netdata='docker run --detach --name netdata --cap-add SYS_PTRACE --volume /proc:/host/proc:ro --volume /sys:/host/sys:ro --volume /var/run/docker.sock:/var/run/docker.sock --publish 19999:19999 firehol/netdata'
 alias json-tool='python3 -m json.tool'
 alias jt='json-tool'
@@ -92,6 +91,14 @@ alias dd='dd status=progress'
 alias screenshot-cleanup='find "$HOME/Pictures" -name "Screenshot from *.png" -delete'
 alias bell='printf \a'
 
+prune_prerun () {
+    local shell_procs="$(pgrep -u "$(id -u)" "$(basename $SHELL)")"
+    for file in $HOME/.prerun.*
+    do
+        echo "file" | grep -qv "$shell_procs" || rm "$file"
+    done
+}
+
 bold () {
     printf '\e[1m'
     echo "$@"
-- 
GitLab