[download]

local/bin/recent

   1 #!/bin/bash
   2 
   3 [[ $1 == -l && $2 -gt 0 ]] && limit=$2 || limit=5
   4 
   5 print(){ # {{{
   6     uniq | while read i; do
   7         i="${i/\~/~}"
   8         i="${i/\$HOME/~}"
   9 
  10         [[ -f $i ]] &&
  11         printf '%s\t%s\n' "$1" "$i"
  12     done | sed ${limit}q
  13 } # }}}
  14 
  15 while IFS=\| read exec file; do
  16     file=${file#file://}
  17     file=$(echo -e "${file//%/\\x}")
  18 
  19     [[ $exec == *godot*    ]] && godot+=("$file")
  20     [[ $exec == *inkscape* ]] && inkscape+=("$file")
  21     [[ $exec == *gimp*     ]] && gimp+=("$file")
  22     [[ $exec == *audacity* ]] && audacity+=("$file")
  23 done < <( # {{{
  24     cat ~/.local/share/recently-used.xbel |
  25     awk -F \" '
  26         /href="/ { file = $2 }
  27         /exec="/ { exec = $4 }
  28         /modified="/ { time = $6 }
  29 
  30         /<bookmark:application / {
  31             printf "%s\t%s|%s\n", time, exec, file
  32         }
  33     ' | sort -r | cut -f 2-
  34 ) # }}}
  35 
  36 {
  37 
  38     test -f ~/.vim/viminfo || : ~/.viminfo
  39     grep '^>' $_ | cut -b 3- | print gvim
  40 
  41     printf '%s\n' "${godot[@]}"    | print godot
  42     printf '%s\n' "${inkscape[@]}" | print inkscape
  43 
  44     cat ~/.config/blender/*/config/recent-files.txt | print blender
  45     sort -Vr ~/.config/kritarc | grep ^File | cut -d = -f 2 | print krita
  46 
  47     printf '%s\n' "${gimp[@]}"     | print gimp
  48     printf '%s\n' "${audacity[@]}" | print audacity
  49 
  50 } | sed "s:$HOME:~:" | awk '!a[$0]++'