diff options
Diffstat (limited to 'dot/local/bin')
-rwxr-xr-x | dot/local/bin/cutbuffer_pop | 19 | ||||
-rwxr-xr-x | dot/local/bin/cutbuffer_push | 20 |
2 files changed, 10 insertions, 29 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 | ||
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 | |||
5 | 5 | ||
6 | destdir=$HOME/$dest_basename | 6 | destdir=$HOME/$dest_basename |
7 | 7 | ||
8 | chdir_to_destination() | ||
9 | { | ||
10 | [ -d "$destdir" ] || mkdir -p "$destdir" | ||
11 | cd "$destdir" | ||
12 | } | ||
13 | |||
14 | choose_destination() | ||
15 | { | ||
16 | now=$(date "$date_format") | ||
17 | DESTINATION=$dest_basename.$now.$dest_extension | ||
18 | } | ||
19 | |||
20 | set -e | 8 | set -e |
21 | 9 | ||
22 | chdir_to_destination | 10 | mkdir -p "$destdir" |
23 | choose_destination | 11 | cd "$destdir" |
24 | xcb -p 0 > "$DESTINATION" | 12 | now=$(date "$date_format") |
13 | dest=$dest_basename.$now.$dest_extension | ||
14 | xcb -p 0 > "$dest" | ||
25 | 15 | ||