From ffe2dc03f03238adf4d1f6d6f8b906bb28466889 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Thu, 25 Aug 2016 01:12:22 +0300 Subject: [PATCH] add an example open-file command to lfrc.example Mentioned in #7. --- etc/lfrc.example | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/etc/lfrc.example b/etc/lfrc.example index 26a2593..de2ef9a 100644 --- a/etc/lfrc.example +++ b/etc/lfrc.example @@ -19,12 +19,20 @@ map read-shell map x $"$f" map X !"$f" -# you can either set your opener to 'mimeopen' -#set opener mimeopen -# or set dedicated keys for specific actions +# dedicated keys for file opener actions map o &mimeopen "$f" map m !mimeopen --ask "$f" +# `open-file` is called by `open` when current file is not a directory +# you may want to use either file extensions or mime types with `file` +# below uses an editor for text files and a file opener for the rest +cmd open-file ${{ + case $(file --mime-type "$f" -b) in + text/*) IFS=':'; vim $fx;; + *) IFS=':'; for f in $fx; do xdg-open "$f" &> /dev/null & done;; + esac +}} + # rename current file without overwrite cmd rename $[ -e "$1" ] || mv "$f" "$1"