summaryrefslogtreecommitdiff
path: root/dot/local/bin/cutbuffer_pop
diff options
context:
space:
mode:
Diffstat (limited to 'dot/local/bin/cutbuffer_pop')
-rwxr-xr-xdot/local/bin/cutbuffer_pop19
1 files changed, 5 insertions, 14 deletions
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
3dest_extension=txt 3dest_extension=txt
4destdir=$HOME/$dest_basename 4destdir=$HOME/$dest_basename
5 5
6chdir_to_destination()
7{
8 [ -d "$destdir" ] || mkdir -p "$destdir"
9 cd "$destdir"
10}
11
12extract()
13{
14 sort -z -n -k1,1 -r | head -z -n 1 | xargs -0 printf '%s\n' | cut -d' ' -f2
15}
16
17set -e 6set -e
7mkdir -p "$destdir"
8cd "$destdir"
18 9
19chdir_to_destination 10nameglob=$dest_basename.*.$dest_extension
20 11f=$(find . -maxdepth 1 -type f -name "$nameglob" -print0 | sort -z -V -r | head -z -n 1 | xargs -0)
21f=$(find . -maxdepth 1 -type f -name "$dest_basename.*.$dest_extension" -printf "%C@ %h/%f\0" | extract)
22 12
23xcb -s 0 < "$f" 13xcb -s 0 < "$f"
24xsel --input < "$f" 14xsel --input < "$f"
15
25mkdir -p .popped 16mkdir -p .popped
26mv "$f" -t .popped 17mv "$f" -t .popped
27 18