Update 'dmenu_path'

This commit is contained in:
Marcin Woźniak 2021-03-29 16:53:04 +02:00
parent 307a593fa6
commit 50b5f34b7a

View File

@ -1,13 +1,24 @@
#!/bin/sh #!/bin/sh
cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" #cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}"
cache="$cachedir/dmenu_run" #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" echo $PATH | tr ':' '\n' | uniq | sed 's#$#/#' | # List directories in $PATH
xargs ls -lu --time-style=+%s | # Add atime epoch
IFS=: awk '/^(-|l)/ { print $6, $7 }' | # Only print timestamp and name
if stest -dqr -n "$cache" $PATH; then sort -rn | cut -d' ' -f 2 | sort -u
stest -flx $PATH | sort -u | tee "$cache"
else
cat "$cache"
fi