commit 95b8cd569846967f40e8fb0b66eee8ca8e9c4cfb
parent 98b959e0d99de0ba0c583ab9f864d2c89787b55a
Author: Chris Down <chris@chrisdown.name>
Date: Sat, 22 Aug 2015 13:13:26 +0100
Limit number of characters displayed in "first line" dmenu selector to 500
Fixes #14.
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git 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%% *}