From 4440a15a8c8c460716c475ae109026b6689840af Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Tue, 15 Nov 2022 21:26:30 +0300 Subject: [PATCH] add the current example open command to the doc cc #991 --- doc.go | 12 ++++++++++++ docstring.go | 16 ++++++++++++++++ etc/lfrc.example | 2 -- lf.1 | 13 +++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/doc.go b/doc.go index 91b7f635..f0897102 100644 --- a/doc.go +++ b/doc.go @@ -1326,6 +1326,18 @@ You may want to use either file extensions or mime types from 'file' command: You may want to use 'setsid' before your opener command to have persistent processes that continue to run after lf quits. +Regular shell commands (i.e. '$') drop to terminal which results in a flicker for commands that finishes immediately (e.g. 'xdg-open' in the above example). +If you want to use asynchronous shell commands (i.e. '&') but also want to use the terminal when necessary (e.g. 'vi' in the above exxample), you can use a remote command: + + cmd open &{{ + case $(file --mime-type -Lb $f) in + text/*) lf -remote "send $id \$vi \$fx";; + *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; + esac + }} + +Note, asynchronous shell commands run in their own process group by default so they do not require the manual use of 'setsid'. + Following command is provided by default: cmd open &$OPENER $f diff --git a/docstring.go b/docstring.go index fb77a29e..9d9fe9a9 100644 --- a/docstring.go +++ b/docstring.go @@ -1429,6 +1429,22 @@ You may want to use either file extensions or mime types from 'file' command: You may want to use 'setsid' before your opener command to have persistent processes that continue to run after lf quits. +Regular shell commands (i.e. '$') drop to terminal which results in a flicker +for commands that finishes immediately (e.g. 'xdg-open' in the above example). +If you want to use asynchronous shell commands (i.e. '&') but also want to use +the terminal when necessary (e.g. 'vi' in the above exxample), you can use a +remote command: + + cmd open &{{ + case $(file --mime-type -Lb $f) in + text/*) lf -remote "send $id \$vi \$fx";; + *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; + esac + }} + +Note, asynchronous shell commands run in their own process group by default so +they do not require the manual use of 'setsid'. + Following command is provided by default: cmd open &$OPENER $f diff --git a/etc/lfrc.example b/etc/lfrc.example index 15730cc1..04fb6c1f 100644 --- a/etc/lfrc.example +++ b/etc/lfrc.example @@ -35,8 +35,6 @@ map O $mimeopen --ask $f # This command is called when current file is not a directory. You may want to # use either file extensions and/or mime types here. Below uses an editor for # text files and a file opener for the rest. -# lf -remote is used here to allow the subshell to work in the background to -# avoid redrawing lf when external applications are opened. cmd open &{{ case $(file --mime-type -Lb $f) in text/*) lf -remote "send $id \$$EDITOR \$fx";; diff --git a/lf.1 b/lf.1 index 99a7a7b1..d8206969 100644 --- a/lf.1 +++ b/lf.1 @@ -1532,6 +1532,19 @@ You may want to use either file extensions or mime types from 'file' command: .PP You may want to use 'setsid' before your opener command to have persistent processes that continue to run after lf quits. .PP +Regular shell commands (i.e. '$') drop to terminal which results in a flicker for commands that finishes immediately (e.g. 'xdg-open' in the above example). If you want to use asynchronous shell commands (i.e. '&') but also want to use the terminal when necessary (e.g. 'vi' in the above exxample), you can use a remote command: +.PP +.EX + cmd open &{{ + case $(file --mime-type -Lb $f) in + text/*) lf -remote "send $id \e$vi \e$fx";; + *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; + esac + }} +.EE +.PP +Note, asynchronous shell commands run in their own process group by default so they do not require the manual use of 'setsid'. +.PP Following command is provided by default: .PP .EX