commit e46b37c793cd10e24f1f52c7fe0d5aa18da4610c parent 4a85fd767cd09cca72a53bba8b2e176ccb8c7d00 Author: Chris Down <chris@chrisdown.name> Date: Wed, 5 Feb 2014 17:12:34 +0800 Add script to run dmenu with selections Diffstat:
A | clipmenu | | | 20 | ++++++++++++++++++++ |
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/clipmenu b/clipmenu @@ -0,0 +1,20 @@ +#!/bin/bash + +dmenu_lines=8 + +declare -A selections + +for file in /tmp/clipmenu/*; do + first_line=$(sed -n '1{p;q}' "$file") + + lines=$(wc -l "$file") + lines=${lines%% *} + + if (( lines > 1 )); then + first_line+=" ($lines lines)" + fi + + selections[$first_line]=$file +done + +printf '%s\n' "${!selections[@]}" | dmenu -l "$dmenu_lines"