sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

run-recent (476B)


      1 #!/bin/sh
      2 # end a command with ; to run in a terminal
      3 
      4 term="st -e"
      5 cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
      6 cache="$cachedir/dmenu_recent"
      7 
      8 touch "$cache"
      9 
     10 most_used=$(sort "$cache" | uniq -c | sort -r | awk '{print $2}')
     11 run=$((echo "$most_used"; dmenu_path | grep -vxF "$most_used") | dmenu -i "$@")
     12 (echo "$run"; head -n 99 "$cache") > "$cache.$$"
     13 mv "$cache.$$" "$cache"
     14 
     15 case "$run" in
     16 	*\;) exec $(echo $term "$run" | sed -e 's/;$//') ;;
     17     *)   exec "$run" ;;
     18 esac