From 50b5f34b7aff1ba41c8c981c879446f7db0122b2 Mon Sep 17 00:00:00 2001 From: y0rune Date: Mon, 29 Mar 2021 16:53:04 +0200 Subject: [PATCH] Update 'dmenu_path' --- dmenu_path | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/dmenu_path b/dmenu_path index 3a7cda7..eb34c52 100755 --- a/dmenu_path +++ b/dmenu_path @@ -1,13 +1,24 @@ #!/bin/sh -cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" -cache="$cachedir/dmenu_run" +#cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" +#cache="$cachedir/dmenu_run" +# +#[ ! -e "$cachedir" ] && mkdir -p "$cachedir" +# +#IFS=: +#if stest -dqr -n "$cache" $PATH; then +# stest -flx $PATH | sort -u | tee "$cache" +#else +# cat "$cache" +#fi +# +# dmenu_path: Override dmenu_path sorting results by atime. +# +# By default, dmenu_path sorts executables alphabetically. It seems to make +# more sense to sort them by atime in an effort to reduce the number of +# keystrokes needed to start a program. -[ ! -e "$cachedir" ] && mkdir -p "$cachedir" - -IFS=: -if stest -dqr -n "$cache" $PATH; then - stest -flx $PATH | sort -u | tee "$cache" -else - cat "$cache" -fi +echo $PATH | tr ':' '\n' | uniq | sed 's#$#/#' | # List directories in $PATH + xargs ls -lu --time-style=+%s | # Add atime epoch + awk '/^(-|l)/ { print $6, $7 }' | # Only print timestamp and name + sort -rn | cut -d' ' -f 2 | sort -u