From 4d30639c6c38ec4e43d61a9274616bffc99c4245 Mon Sep 17 00:00:00 2001 From: Roy Orbitson Date: Thu, 15 Feb 2024 14:59:48 +1030 Subject: [PATCH] Always act as file picker when instructed Should not be conditional on MIME type, otherwise many types, e.g.: application/javascript, can never be selected and will instead open in a separate program or instance. --- fff | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fff b/fff index 16766e3..e354496 100755 --- a/fff +++ b/fff @@ -592,6 +592,14 @@ open() { redraw full elif [[ -f $1 ]]; then + # If 'fff' was opened as a file picker, save the opened + # file in a file called 'opened_file'. + ((file_picker == 1)) && { + printf '%s\n' "$1" > \ + "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/opened_file" + exit + } + # Figure out what kind of file we're working with. get_mime_type "$1" @@ -599,14 +607,6 @@ open() { # Everything else goes through 'xdg-open'/'open'. case "$mime_type" in text/*|*x-empty*|*json*) - # If 'fff' was opened as a file picker, save the opened - # file in a file called 'opened_file'. - ((file_picker == 1)) && { - printf '%s\n' "$1" > \ - "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/opened_file" - exit - } - clear_screen reset_terminal "${VISUAL:-${EDITOR:-vi}}" "$1"