clipmenu

Simple clipboard management using dmenu
git clone https://git.sinitax.com/cdown/clipmenu
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 0418bf2e6db9b2c9722e580ff689b4b8c2c1f198
parent 5b2754868b88c143f44a97163cbf4d7e93ccbd35
Author: Chris Down <chris@chrisdown.name>
Date:   Sun, 12 Apr 2015 18:51:46 +0100

Sort selections by recency

Fixes #5.

Diffstat:
Mclipmenu | 15+++++++++++++--
Mclipmenud | 2+-
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clipmenu b/clipmenu @@ -1,10 +1,17 @@ #!/bin/bash +LC_COLLATE=C + dmenu_lines=${CLIPMENU_LINES-8} declare -A selections +ordered_selections=() + +files=("/tmp/clipmenu.$USER/"*) + +for (( i=${#files[@]}-1; i>=0; i-- )); do + file=${files[$i]} -for file in /tmp/clipmenu.$USER/*; do first_line=$(sed -n '/./{p;q}' "$file") lines=$(wc -l "$file") @@ -14,10 +21,14 @@ for file in /tmp/clipmenu.$USER/*; do first_line+=" ($lines lines)" fi + ordered_selections+=("$first_line") selections[$first_line]=$file done -chosen_line=$(printf '%s\n' "${!selections[@]}" | dmenu -l "$dmenu_lines" "$@") +chosen_line=$( + printf '%s\n' "${ordered_selections[@]}" | + awk '!x[$0]++' | dmenu -l "$dmenu_lines" "$@" +) [[ $chosen_line ]] || exit 1 diff --git a/clipmenud b/clipmenud @@ -23,6 +23,6 @@ while sleep 1; do md5=$(md5sum <<< "$data") md5=${md5%% *} - printf '%s' "$data" > "$cache_dir/$md5" + printf '%s' "$data" > "$cache_dir/$(LC_ALL=C date +%F-%H-%M-%S)-$md5" done done