X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu_path;h=7896a9e957fa1e274805c0641c841a6b82334667;hb=569a1f925a7cf351e6ec3e38529f46a1d9becf3f;hp=72ff3ed416ed2fb67d5b0d6e83bd28b33e7da827;hpb=68a24f5535030473e90426c30fafe75262add419;p=dmenu.git diff --git a/dmenu_path b/dmenu_path index 72ff3ed..7896a9e 100755 --- a/dmenu_path +++ b/dmenu_path @@ -1,2 +1,26 @@ #!/bin/sh -/bin/ls -lL `echo $PATH | tr : ' '` 2> /dev/null | awk '$1 ~ /^[^d].*x/ { print $NF }' | sort | uniq +CACHE=$HOME/.dmenu_cache +IFS=: + +uptodate() { + test -f "$CACHE" && + for dir in $PATH + do + test ! $dir -nt "$CACHE" || return 1 + done +} + +if ! uptodate +then + for dir in $PATH + do + cd "$dir" && + for file in * + do + test -x "$file" && echo "$file" + done + done | sort | uniq > "$CACHE".$$ && + mv "$CACHE".$$ "$CACHE" +fi + +cat "$CACHE"