commit f04687cc79f065e9ebed46714bbb90071619aaf6
Author: ananthu <[email protected]>
Date: Mon Jul 13 22:09:47 2020 +0530
Fixed new line insertion issue in cache file when the entries are not
selected and optimised code.
diff --git a/tools.suckless.org/dmenu/scripts/run-recent
b/tools.suckless.org/dmenu/scripts/run-recent
index 7e99c5fc..7c81bc6f 100755
--- a/tools.suckless.org/dmenu/scripts/run-recent
+++ b/tools.suckless.org/dmenu/scripts/run-recent
@@ -7,12 +7,12 @@ cache="$cachedir/dmenu_recent"
touch "$cache"
-most_used=$(sort "$cache" | uniq -c | sort -r | awk '{print $2}')
+most_used=$(sort "$cache" | uniq -c | sort -r | cut -d" " -f8)
run=$((echo "$most_used"; dmenu_path | grep -vxF "$most_used") | dmenu -i "$@")
-(echo "$run"; head -n 99 "$cache") > "$cache.$$"
+([ -z "$run" ] || echo "$run"; head -n 99 "$cache") > "$cache.$$"
mv "$cache.$$" "$cache"
case "$run" in
- *\;) exec $(echo $term "$run" | sed -e 's/;$//') ;;
+ *\;) exec $(echo $term ${run%;}) ;;
*) exec "$run" ;;
esac