fff
fff copied to clipboard
Example '$FFF_OPENER' script
#!/usr/bin/env bash
#
# opener
[[ -z $1 || ! -e $1 ]] &&
exit 1
mime_type="$(file -biL "$1")"
case "$mime_type" in
text/*|*/xml)
"${VISUAL:-${EDITOR:-vi}}" "$1"
;;
image/*)
qiv -tBl "$1"
;;
video/*)
mpv "$1"
;;
audio/*)
mpv "$1"
;;
application/pdf*)
"${BROWSER:-firefox}" "$1"
;;
*opendocument*|*openxmlformats*)
libreoffice "$1"
;;
*)
printf '%s\n' "warn: No program defined for $mime_type"
;;
esac
Thanks! I'm currently using this script. But I switched from file to perl-file-mimeinfo because it follows the XDG standard.
I have expanded on this idea to create a file-opener script https://github.com/Docbroke/opener
However to use this with fff, some code change is needed. Under the funciton open() entire case statement for file opening may be replaced with below code
clear_screen
reset_terminal
opener "$1"
setup_terminal
redraw
I have removed nohup and redirection of terminal output to allow for terminal commands,