clipmenu

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

commit 48b1ebf9fbe20153165ace0f3d290bb1d8a7637a
parent 6855d24e3a3393c124e18a4dacc5d007eb463a3a
Author: Chris Down <chris@chrisdown.name>
Date:   Tue, 24 Oct 2017 22:53:54 +0200

If CM_MAX_CLIPS is 0, don't truncate

Diffstat:
Mclipmenud | 24+++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/clipmenud b/clipmenud @@ -146,17 +146,19 @@ while (( CM_ONESHOT )) || sleep "${CM_SLEEP:-0.5}"; do _xsel -o --"$selection" | _xsel -i --"$selection" fi - mapfile -t to_remove < <( - head -n -"$CM_MAX_CLIPS" "$cache_file" | - while read -r line; do cksum <<< "$line"; done - ) - num_to_remove="${#to_remove[@]}" - if (( num_to_remove )); then - debug "Removing $num_to_remove old clips" - rm -- "${to_remove[@]/#/"$cache_dir/"}" - trunc_tmp=$(mktemp) - tail -n "$CM_MAX_CLIPS" "$cache_file" | uniq > "$trunc_tmp" - mv -- "$trunc_tmp" "$cache_file" + if (( CM_MAX_CLIPS )); then + mapfile -t to_remove < <( + head -n -"$CM_MAX_CLIPS" "$cache_file" | + while read -r line; do cksum <<< "$line"; done + ) + num_to_remove="${#to_remove[@]}" + if (( num_to_remove )); then + debug "Removing $num_to_remove old clips" + rm -- "${to_remove[@]/#/"$cache_dir/"}" + trunc_tmp=$(mktemp) + tail -n "$CM_MAX_CLIPS" "$cache_file" | uniq > "$trunc_tmp" + mv -- "$trunc_tmp" "$cache_file" + fi fi done