From 847addaf67b82c6e39d9c47518b50c4641212f41 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 14 Sep 2021 03:37:33 -0400 Subject: cutbuffer finaller cleanup --- dot/local/bin/cutbuffer_pop | 19 +++++-------------- dot/local/bin/cutbuffer_push | 20 +++++--------------- 2 files changed, 10 insertions(+), 29 deletions(-) (limited to 'dot') diff --git a/dot/local/bin/cutbuffer_pop b/dot/local/bin/cutbuffer_pop index d723a27..e994342 100755 --- a/dot/local/bin/cutbuffer_pop +++ b/dot/local/bin/cutbuffer_pop @@ -3,25 +3,16 @@ dest_basename=cutbuffer_grab dest_extension=txt destdir=$HOME/$dest_basename -chdir_to_destination() -{ - [ -d "$destdir" ] || mkdir -p "$destdir" - cd "$destdir" -} - -extract() -{ - sort -z -n -k1,1 -r | head -z -n 1 | xargs -0 printf '%s\n' | cut -d' ' -f2 -} - set -e +mkdir -p "$destdir" +cd "$destdir" -chdir_to_destination - -f=$(find . -maxdepth 1 -type f -name "$dest_basename.*.$dest_extension" -printf "%C@ %h/%f\0" | extract) +nameglob=$dest_basename.*.$dest_extension +f=$(find . -maxdepth 1 -type f -name "$nameglob" -print0 | sort -z -V -r | head -z -n 1 | xargs -0) xcb -s 0 < "$f" xsel --input < "$f" + mkdir -p .popped mv "$f" -t .popped diff --git a/dot/local/bin/cutbuffer_push b/dot/local/bin/cutbuffer_push index cad9367..ab3ca98 100755 --- a/dot/local/bin/cutbuffer_push +++ b/dot/local/bin/cutbuffer_push @@ -5,21 +5,11 @@ date_format=+%F_%H%M%S destdir=$HOME/$dest_basename -chdir_to_destination() -{ - [ -d "$destdir" ] || mkdir -p "$destdir" - cd "$destdir" -} - -choose_destination() -{ - now=$(date "$date_format") - DESTINATION=$dest_basename.$now.$dest_extension -} - set -e -chdir_to_destination -choose_destination -xcb -p 0 > "$DESTINATION" +mkdir -p "$destdir" +cd "$destdir" +now=$(date "$date_format") +dest=$dest_basename.$now.$dest_extension +xcb -p 0 > "$dest" -- cgit v1.2.3