diff --git a/doc.go b/doc.go index bc0c179b..0f85b84e 100644 --- a/doc.go +++ b/doc.go @@ -503,20 +503,20 @@ completely are provided in the example configuration file. Opening Files -You can use 'open-file' command to open a file. This is a special command -called by 'open' when the current file is not a directory. Normally a user maps -the 'open' command to a key (default 'l') and customize 'open-file' command as -desired. You can define it just as you would define any other command: +You can define a an 'open' command (default 'l') to configure file opening. +This command is only called when the current file is not a directory, otherwise +the directory is entered instead. You can define it just as you would define +any other command: - cmd open-file $vi $fx + cmd open $vi $fx It is possible to use different command types: - cmd open-file &xdg-open $f + cmd open &xdg-open $f You may want to use either file extensions or mime types from 'file' command: - cmd open-file ${{ + cmd open ${{ case $(file --mime-type $f -b) in text/*) vi $fx;; *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; @@ -525,9 +525,9 @@ You may want to use either file extensions or mime types from 'file' command: Following commands are provided by default: - cmd open-file &start %f% # windows - cmd open-file &open "$f" # macos - cmd open-file &xdg-open "$f" # others + cmd open &start %f% # windows + cmd open &open "$f" # macos + cmd open &xdg-open "$f" # others You may also use any other existing file openers as you like. Possible options are 'libfile-mimeinfo-perl' (executable name is 'mimeopen'), 'rifle' (ranger's diff --git a/docstring.go b/docstring.go index 29f4b60b..96e232ad 100644 --- a/docstring.go +++ b/docstring.go @@ -529,22 +529,21 @@ files completely are provided in the example configuration file. Opening Files -You can use 'open-file' command to open a file. This is a special command -called by 'open' when the current file is not a directory. Normally a user -maps the 'open' command to a key (default 'l') and customize 'open-file' -command as desired. You can define it just as you would define any other -command: +You can define a an 'open' command (default 'l') to configure file opening. +This command is only called when the current file is not a directory, +otherwise the directory is entered instead. You can define it just as you +would define any other command: - cmd open-file $vi $fx + cmd open $vi $fx It is possible to use different command types: - cmd open-file &xdg-open $f + cmd open &xdg-open $f You may want to use either file extensions or mime types from 'file' command: - cmd open-file ${{ + cmd open ${{ case $(file --mime-type $f -b) in text/*) vi $fx;; *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; @@ -553,9 +552,9 @@ command: Following commands are provided by default: - cmd open-file &start %f% # windows - cmd open-file &open "$f" # macos - cmd open-file &xdg-open "$f" # others + cmd open &start %f% # windows + cmd open &open "$f" # macos + cmd open &xdg-open "$f" # others You may also use any other existing file openers as you like. Possible options are 'libfile-mimeinfo-perl' (executable name is 'mimeopen'), 'rifle' diff --git a/etc/lfrc.example b/etc/lfrc.example index a76515e7..462c0a57 100644 --- a/etc/lfrc.example +++ b/etc/lfrc.example @@ -34,11 +34,11 @@ map O $mimeopen --ask $f # show documentation (overrides 'search-back' command) map ? $lf -doc | less -# define a custom 'open-file' command -# 'open-file' is called by 'open' 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. -cmd open-file ${{ +# define a custom 'open' command +# 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. +cmd open ${{ case $(file --mime-type $f -b) in text/*) vi $fx;; *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; diff --git a/eval.go b/eval.go index 1db946b1..58d1e967 100644 --- a/eval.go +++ b/eval.go @@ -333,7 +333,7 @@ func (e *callExpr) eval(app *app, args []string) { return } - if cmd, ok := gOpts.cmds["open-file"]; ok { + if cmd, ok := gOpts.cmds["open"]; ok { cmd.eval(app, e.args) } case "quit": diff --git a/os.go b/os.go index 273d6aaf..09ffdbff 100644 --- a/os.go +++ b/os.go @@ -118,9 +118,9 @@ func setDefaults() { } if runtime.GOOS == "darwin" { - gOpts.cmds["open-file"] = &execExpr{"&", `open "$f"`} + gOpts.cmds["open"] = &execExpr{"&", `open "$f"`} } else { - gOpts.cmds["open-file"] = &execExpr{"&", `xdg-open "$f"`} + gOpts.cmds["open"] = &execExpr{"&", `xdg-open "$f"`} } } diff --git a/os_windows.go b/os_windows.go index 0303c71e..4bfaa86d 100644 --- a/os_windows.go +++ b/os_windows.go @@ -79,7 +79,7 @@ func setDefaults() { gOpts.keys["e"] = &execExpr{"$", `notepad %f%`} gOpts.keys["i"] = &execExpr{"$", `more %f%`} gOpts.keys["w"] = &execExpr{"$", "cmd"} - gOpts.cmds["open-file"] = &execExpr{"&", `start %f%`} + gOpts.cmds["open"] = &execExpr{"&", `start %f%`} } func moveCursor(y, x int) {