#!/bin/sh

selected=$(fzf --no-multi --preview-window 'left:60%' --preview '$HOME/.local/bin/garbage/preview {} 2>/dev/null')
mimetype=$(file -b --mime-type "$selected")

case "$mimetype" in
  *.doc|*.docx|*.odt|*.ott|*.xls|*.xlsx|*.xlsmx|*.ods|*.odp|*.sxc|*.ppt|*.pptx) libreoffice "$selected" & ;;
  *.pdf|*.cbz|*.cbr|*.cbt|*.cba|*.djvu) zathura "$selected" & ;;
  text/* | */xml) $EDITOR "$selected" ;;
  *) xdg-open "$selected" >/dev/null 2>&1 & ;;
esac
