Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- locatedb=/var/lib/mlocate/mlocate.db # 'locate' database file, very likely here
- cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
- if [ -d "$cachedir" ]
- then
- cache=$cachedir/dmenu_open
- else # if no xdg dir, fall back to dotfile in ~
- cache=$HOME/.dmenu_open
- fi
- if [ ! -f "$cache" ] || [ "$cache" -ot "$locatedb" ]
- # ie: if the cache file exists OR if the cache is older than the lcoatedb
- then
- nohidden="/\/\./d" # removes all hidden files from the list
- striphome="s#$HOME/##" # strips home directory suffix
- locate -r "^$HOME/" | sed "$nohidden; $striphome" | tee "$cache"
- else
- cat "$cache"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement