From 95b8cd569846967f40e8fb0b66eee8ca8e9c4cfb Mon Sep 17 00:00:00 2001 From: Chris Down Date: Sat, 22 Aug 2015 13:13:26 +0100 Subject: [PATCH] Limit number of characters displayed in "first line" dmenu selector to 500 Fixes #14. --- clipmenu | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clipmenu b/clipmenu index 5f8a9e8..b63a3fe 100755 --- a/clipmenu +++ b/clipmenu @@ -2,6 +2,9 @@ LC_COLLATE=C +# Some people copy/paste huge swathes of text that could slow down dmenu +line_length_limit=500 + declare -A selections ordered_selections=() @@ -10,7 +13,7 @@ files=("/tmp/clipmenu.$USER/"*) for (( i=${#files[@]}-1; i>=0; i-- )); do file=${files[$i]} - first_line=$(sed -n '/./{p;q}' "$file") + first_line=$(sed -n '/./{p;q}' "$file" | cut -c1-"$line_length_limit") lines=$(wc -l "$file") lines=${lines%% *}