From 55e3100bfb109e1d8e9c8f16fb55f4ec60b985e2 Mon Sep 17 00:00:00 2001 From: Jeremy Kaplan Date: Thu, 4 Aug 2022 15:43:20 -0700 Subject: [PATCH] bin: Fix pbedit trailing newlines --- bin/pbedit | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/pbedit b/bin/pbedit index 211ea85..29b6ec0 100755 --- a/bin/pbedit +++ b/bin/pbedit @@ -1,3 +1,7 @@ #!/bin/sh -pbpaste | vipe | pbcopy +# Somehow, this pipeline ends up with a bunch of newlines at the end that make +# pasting it annoying. Use sed to remove all trailing newlines. +# +# https://stackoverflow.com/a/7359879/2472163 +pbpaste | vipe | sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' | pbcopy