#!/bin/sh #To add more caches, add a newline to this string and follow the existing name:path format cache_info="home:$HOME" init() { mkdir -p $XDG_CACHE_HOME/mru } get_cache_path() { if [ -z "$1" ]; then printf "invalid arg to cache_path\n"; exit; fi } update() { file=$XDG_CACHE_HOME/mru/"$1" if [ -z "$1" ]; then file="$file""home"; fi path=$(printf $cache_info | grep "^$1" - | cut -d: -f2) if [ -z "$path" -o ! -e "$path" ]; then printf "path:$path from cache:$file does not exist\n"; exit; fi find $path -type f -not \( -path '*/.*/*' -o -path '*node_modules/*' -o \ -path '*Backups/my-plugins*' -o -path '*.sw[po]' \) -printf \ '%TY-%Tm-%Td\t%TT\t%p\n' | sort -r > $file } output() { if [ -z "$2" ]; then cat $XDG_CACHE_HOME/mru/home; else cat "$XDG_CACHE_HOME/mru/$2"; fi } list() { output "$1" | cut -f3 } case "$1" in init) init "$2";; update) update $2;; output) output "$2";; list) list "$2";; insert) insert "$2";; esac