X-Git-Url: https://git.xinqibao.xyz/dmenu.git/blobdiff_plain/68a24f5535030473e90426c30fafe75262add419..8b633bf17de71ffec76b2413c23c01bb705c36b8:/dmenu_path?ds=inline diff --git a/dmenu_path b/dmenu_path index 72ff3ed..e725ede 100755 --- a/dmenu_path +++ b/dmenu_path @@ -1,2 +1,32 @@ #!/bin/sh -/bin/ls -lL `echo $PATH | tr : ' '` 2> /dev/null | awk '$1 ~ /^[^d].*x/ { print $NF }' | sort | uniq +CACHE=$HOME/.dmenu_cache +UPTODATE=1 +IFS=: + +uptodate() { [ $UPTODATE -eq 1 ]; } + +if test ! -f $CACHE +then + UPTODATE=0 +fi + +if uptodate +then + for dir in $PATH + do + test $dir -nt $CACHE && { UPTODATE=0; break; } + done +fi + +if ! uptodate +then + for dir in $PATH + do + for file in "$dir"/* + do + test -x "$file" && echo "${file##*/}" + done + done | sort | uniq > $CACHE +fi + +cat $CACHE