aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xclip22
1 files changed, 16 insertions, 6 deletions
diff --git a/clip b/clip
index eff2d6f..4f1ae25 100755
--- a/clip
+++ b/clip
@@ -1,9 +1,11 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# A primitive clipboard manager. Saves the current selection to a temporary 3# A primitive clipboard manager. Saves the current selection and clipboard
4# file and shows all saved selections in dmenu for the user to select one. 4# to a temporary file and shows all saved selections in dmenu for the user
5# It does not check for duplicates and it fails if there it can't 5# to select one. Duplicate selections are avoided.
6# create the temporary directory with the designated name. 6
7# Bugs (wontfix): the program fails if it can't create the temporary
8# directory with the designated name.
7 9
8# Requires: xsel, dmenu 10# Requires: xsel, dmenu
9 11
@@ -15,8 +17,16 @@ menuopts="-l 25"
15dir="/tmp/clipdir" 17dir="/tmp/clipdir"
16mkdir -p "$dir" 18mkdir -p "$dir"
17 19
18file="$(mktemp -p $dir $(date +%s).XXXXX)" 20file1="$(mktemp -p $dir $(date +%s).XXXXX)"
19xsel > "$file" 21file2="$(mktemp -p $dir $(date +%s)b.XXXX)"
22xsel > "$file1"
23xsel -b > "$file2"
24
25# Avoid duplicates
26for f in $dir/*; do
27 [ "$f" != "$file1" ] && if diff "$f" "$file1"; then rm "$file1"; fi
28 [ "$f" != "$file2" ] && if diff "$f" "$file2"; then rm "$file2"; fi
29done
20 30
21list="$(mktemp)" 31list="$(mktemp)"
22ls $dir > $list; 32ls $dir > $list;

Generated with cgit - Back to sebastiano.tronto.net