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