This commit is contained in:
Gokcehan committed 2017-09-08 23:46:31 +03:00
1 parent 3e0361911b
commit 1df7ca3408
4 files changed
+159 -176

No files matched your search

+12 -7
View File
@@ -11,8 +11,8 @@
`lf` (as in "list files") is a terminal file manager written in Go. `lf` (as in "list files") is a terminal file manager written in Go.
It is heavily inspired by ranger with some missing and extra features. It is heavily inspired by ranger with some missing and extra features.
Some of the missing features are deliberately omitted Some of the missing features are deliberately omitted since they are better handled by external tools.
since it is better if they are handled by external tools. See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information.
![multicol-screenshot](http://i.imgur.com/DaTUenu.png) ![multicol-screenshot](http://i.imgur.com/DaTUenu.png)
![singlecol-screenshot](http://i.imgur.com/p95xzUj.png) ![singlecol-screenshot](http://i.imgur.com/p95xzUj.png)
@@ -23,15 +23,14 @@ since it is better if they are handled by external tools.
- Single binary without any runtime dependencies (except for terminfo database) - Single binary without any runtime dependencies (except for terminfo database)
- Fast startup and low memory footprint (due to native code and static binaries) - Fast startup and low memory footprint (due to native code and static binaries)
- Server/client architecture to share file selection between multiple instances - Server/client architecture to share file selection between multiple instances
- Custom commands as shell commands - Configurable with shell commands (sync or async)
- Sync (waiting and non-waiting) and async commands - Customizable keybindings (vi and readline defaults)
- Fully customizable keybindings
- Preview filtering (for source highlight, archives, pdfs/images as text etc.) - Preview filtering (for source highlight, archives, pdfs/images as text etc.)
## Non-Features ## Non-Features
- Tabs or windows (handled by the window manager or the terminal multiplexer) - Tabs or windows (handled by window manager or terminal multiplexer)
- Built-in pager (handled by your pager of choice) - Builtin pager/editor (handled by your pager/editor of choice)
- Image previews (cool but no standard available) - Image previews (cool but no standard available)
## May-Futures ## May-Futures
@@ -59,3 +58,9 @@ Run `lf -doc` to see the [documentation](https://godoc.org/github.com/gokcehan/l
See [etc](etc) directory to integrate `lf` to your shell or editor. See [etc](etc) directory to integrate `lf` to your shell or editor.
An example configuration file can also be found in this directory. An example configuration file can also be found in this directory.
See [tips](https://github.com/gokcehan/lf/wiki/Tips) for more examples.
## Contributing
See [contributing](https://github.com/gokcehan/lf/wiki/Contributing) for guidelines.
+121 -129
View File
@@ -5,39 +5,39 @@ lf is a terminal file manager.
Source code can be found in the repository at https://github.com/gokcehan/lf. Source code can be found in the repository at https://github.com/gokcehan/lf.
This documentation can either be read from terminal using "lf -doc" or online This documentation can either be read from terminal using 'lf -doc' or online
at https://godoc.org/github.com/gokcehan/lf. at https://godoc.org/github.com/gokcehan/lf.
Reference Reference
The following commands are provided by lf with default keybindings: The following commands are provided by lf with default keybindings:
up (default "k" and "<up>") up (default 'k' and '<up>')
half-up (default "<c-u>") half-up (default '<c-u>')
page-up (default "<c-b>") page-up (default '<c-b>')
down (default "j" and "<down>") down (default 'j' and '<down>')
half-down (default "<c-d>") half-down (default '<c-d>')
page-down (default "<c-f>") page-down (default '<c-f>')
updir (default "h" and "<left>") updir (default 'h' and '<left>')
open (default "l" and "<right>") open (default 'l' and '<right>')
quit (default "q") quit (default 'q')
bot (default "G") bot (default 'G')
top (default "gg") top (default 'gg')
read (default ":") read (default ':')
read-shell (default "$") read-shell (default '$')
read-shell-wait (default "!") read-shell-wait (default '!')
read-shell-async (default "&") read-shell-async (default '&')
search (default "/") search (default '/')
search-back (default "?") search-back (default '?')
search-next (default "n") search-next (default 'n')
search-prev (default "N") search-prev (default 'N')
toggle (default "<space>") toggle (default '<space>')
invert (default "v") invert (default 'v')
yank (default "y") yank (default 'y')
clear (default "c") clear (default 'c')
delete (default "d") delete (default 'd')
put (default "p") put (default 'p')
renew (default "<c-l>") renew (default '<c-l>')
The following commands are provided by lf without default keybindings: The following commands are provided by lf without default keybindings:
@@ -49,22 +49,22 @@ The following commands are provided by lf without default keybindings:
The following command line commands are provided by lf with default The following command line commands are provided by lf with default
keybindings: keybindings:
cmd-escape (default "<esc>") cmd-escape (default '<esc>')
cmd-comp (default "<tab>") cmd-comp (default '<tab>')
cmd-enter (default "<c-j>" and "<enter>") cmd-enter (default '<c-j>' and '<enter>')
cmd-hist-next (default "<c-n>") cmd-hist-next (default '<c-n>')
cmd-hist-prev (default "<c-p>") cmd-hist-prev (default '<c-p>')
cmd-delete (default "<c-d>" and "<delete>") cmd-delete (default '<c-d>' and '<delete>')
cmd-delete-back (default "<bs>" and "<bs2>") cmd-delete-back (default '<bs>' and '<bs2>')
cmd-left (default "<c-b>" and "<left>") cmd-left (default '<c-b>' and '<left>')
cmd-right (default "<c-f>" and "<right>") cmd-right (default '<c-f>' and '<right>')
cmd-beg (default "<c-a>" and "<home>") cmd-beg (default '<c-a>' and '<home>')
cmd-end (default "<c-e>" and "<end>") cmd-end (default '<c-e>' and '<end>')
cmd-delete-end (default "<c-k>") cmd-delete-end (default '<c-k>')
cmd-delete-beg (default "<c-u>") cmd-delete-beg (default '<c-u>')
cmd-delete-word (default "<c-w>") cmd-delete-word (default '<c-w>')
cmd-put (default "<c-y>") cmd-put (default '<c-y>')
cmd-transpose (default "<c-t>") cmd-transpose (default '<c-t>')
The following options can be used to customize the behavior of lf: The following options can be used to customize the behavior of lf:
@@ -80,13 +80,13 @@ The following options can be used to customize the behavior of lf:
scrolloff integer (default 0) scrolloff integer (default 0)
tabstop integer (default 8) tabstop integer (default 8)
filesep string (default "\n") filesep string (default "\n")
ifs string (default "") (not exported if empty) ifs string (default '') (not exported if empty)
previewer string (default "") (not filtered if empty) previewer string (default '') (not filtered if empty)
shell string (default "/bin/sh") shell string (default '/bin/sh')
sortby string (default "natural") sortby string (default 'natural')
timefmt string (default "Mon Jan _2 15:04:05 2006") timefmt string (default 'Mon Jan _2 15:04:05 2006')
ratios string (default "1:2:3") ratios string (default '1:2:3')
info string (default "") info string (default '')
The following variables are exported for shell commands: The following variables are exported for shell commands:
@@ -99,9 +99,9 @@ Configuration
The configuration file should be located at: The configuration file should be located at:
$XDG_CONFIG_HOME/lf/lfrc" $XDG_CONFIG_HOME/lf/lfrc
If "$XDG_CONFIG_HOME" is not set, it defaults to "$HOME/.config" so the If '$XDG_CONFIG_HOME' is not set, it defaults to '$HOME/.config' so the
location should be: location should be:
~/.config/lf/lfrc ~/.config/lf/lfrc
@@ -113,7 +113,7 @@ Prefixes
The following command prefixes are used by lf: The following command prefixes are used by lf:
: read (default) built-in command : read (default) builtin/custom command
$ read-shell shell command $ read-shell shell command
! read-shell-wait shell command waiting for key press ! read-shell-wait shell command waiting for key press
& read-shell-async asynchronous shell command & read-shell-async asynchronous shell command
@@ -127,14 +127,14 @@ default these modes are mapped to the prefix keys above.
Syntax Syntax
Characters from "#" to "\n" are comments and ignored: Characters from '#' to newline are comments and ignored:
# comments start with '#' # comments start with '#'
There are three special commands ("set", "map", and "cmd") and their variants There are three special commands ('set', 'map', and 'cmd') and their variants
for configuration. for configuration.
"set" is used to set an option which can be boolean, integer, or string: 'set' is used to set an option which can be boolean, integer, or string:
set hidden # boolean on set hidden # boolean on
set nohidden # boolean off set nohidden # boolean off
@@ -144,16 +144,16 @@ for configuration.
set sortby 'time' # string value with single quotes (whitespaces) set sortby 'time' # string value with single quotes (whitespaces)
set sortby "time" # string value with double quotes (backslash escapes) set sortby "time" # string value with double quotes (backslash escapes)
"map" is used to bind a key to a command which can be built-in command, custom 'map' is used to bind a key to a command which can be builtin command, custom
command, or shell command: command, or shell command:
map gh cd ~ # built-in command map gh cd ~ # builtin command
map D trash # custom command map D trash # custom command
map i $less "$f" # shell command map i $less $f # shell command
map u !du -h . # waiting shell command map u !du -h . # waiting shell command
"cmap" is used to bind a key to a command line command which can only be one of 'cmap' is used to bind a key to a command line command which can only be one of
the built-in commands: the builtin commands:
cmap <c-g> cmd-escape cmap <c-g> cmd-escape
@@ -162,24 +162,24 @@ You can delete an existing binding by leaving the expression empty:
map gh # deletes 'gh' mapping map gh # deletes 'gh' mapping
cmap <c-g> # deletes '<c-g>' mapping cmap <c-g> # deletes '<c-g>' mapping
"cmd" is used to define a custom command 'cmd' is used to define a custom command
cmd usage $du -h . | less cmd usage $du -h . | less
You can delete an existing command by leaving the expression empty: You can delete an existing command by leaving the expression empty:
cmd trash # deletes trash command cmd trash # deletes 'trash' command
If there is no prefix then ":" is assumed: If there is no prefix then ':' is assumed:
map zt set info time map zt set info time
An explicit ":" can be provided to group statements until a "\n" occurs which An explicit ':' can be provided to group statements until a newline which is
is especially useful for "map" and "cmd" commands: especially useful for 'map' and 'cmd' commands:
map st :set sortby time; set info time map st :set sortby time; set info time
If you need multiline you can wrap statements in "{{" and "}}" after the proper If you need multiline you can wrap statements in '{{' and '}}' after the proper
prefix. prefix.
map st :{{ map st :{{
@@ -191,9 +191,9 @@ Mappings
The usual way to map a key sequence is to assign it to a named or unnamed The usual way to map a key sequence is to assign it to a named or unnamed
command. While this provides a clean way to remap builtin keys as well as other command. While this provides a clean way to remap builtin keys as well as other
commands, it can be limiting at times. For this reason "push" command is commands, it can be limiting at times. For this reason 'push' command is
provided by lf. This command is used to simulate key pushes given as its provided by lf. This command is used to simulate key pushes given as its
arguments. You can "map" a key to a "push" command with an argument to create arguments. You can 'map' a key to a 'push' command with an argument to create
various keybindings. various keybindings.
This is mainly useful for two purposes. First, it can be used to map a command This is mainly useful for two purposes. First, it can be used to map a command
@@ -205,7 +205,7 @@ Second, it can be used to avoid typing the name when a command takes arguments:
map r push :rename<space> map r push :rename<space>
One thing to be careful is that since "push" command works with keys instead of One thing to be careful is that since 'push' command works with keys instead of
commands it is possible to accidentally create recursive bindings: commands it is possible to accidentally create recursive bindings:
map j push 2j map j push 2j
@@ -228,8 +228,8 @@ A first attempt to write such a command may look like this:
fi fi
}} }}
We check "$fs" to see if there are any marked files. Otherwise we just delete We check '$fs' to see if there are any marked files. Otherwise we just delete
the current file. Since this is such a common pattern, a separate "$fx" the current file. Since this is such a common pattern, a separate '$fx'
variable is provided. We can use this variable to get rid of the conditional: variable is provided. We can use this variable to get rid of the conditional:
cmd trash ${{ cmd trash ${{
@@ -244,16 +244,16 @@ it outside of the command so it would only run once at startup:
cmd trash ${{ IFS="`printf '\n\t'`"; mv --backup=numbered $fx ~/.trash }} cmd trash ${{ IFS="`printf '\n\t'`"; mv --backup=numbered $fx ~/.trash }}
Since these are one liners, we can drop "{{" and "}}": Since these are one liners, we can drop '{{' and '}}':
$mkdir -p ~/.trash $mkdir -p ~/.trash
cmd trash $IFS="`printf '\n\t'`"; mv --backup=numbered $fx ~/.trash cmd trash $IFS="`printf '\n\t'`"; mv --backup=numbered $fx ~/.trash
Finally note that we set "IFS" variable manually in these commands. Instead we Finally note that we set 'IFS' variable manually in these commands. Instead we
could use the "ifs" option to set it for all shell commands (i.e. 'set ifs could use the 'ifs' option to set it for all shell commands (i.e. 'set ifs
"\n"'). This can be especially useful for interactive use (e.g. "$rm $f" or "\n"'). This can be especially useful for interactive use (e.g. '$rm $f' or
"$rm $fs" would simply work). This option is not set by default as it can '$rm $fs' would simply work). This option is not set by default as it can
behave unexpectedly for new users. However, use of this option is highly behave unexpectedly for new users. However, use of this option is highly
recommended and it is assumed in the rest of the documentation. recommended and it is assumed in the rest of the documentation.
@@ -277,14 +277,14 @@ commands since it is shorter and immune to socket file address changes:
lf -remote 'send echo hello world' lf -remote 'send echo hello world'
In this command "send" is used to send the rest of the string as a command to In this command 'send' is used to send the rest of the string as a command to
all connected clients. You can optionally give it an id number to send a all connected clients. You can optionally give it an id number to send a
command to a single client: command to a single client:
lf -remote 'send 1000 echo hello world' lf -remote 'send 1000 echo hello world'
All clients have a unique id number but you may not be aware of the id number All clients have a unique id number but you may not be aware of the id number
when you are writing a command. For this purpose, an "$id" variable is exported when you are writing a command. For this purpose, an '$id' variable is exported
to the environment for shell commands. You can use it to send a remote command to the environment for shell commands. You can use it to send a remote command
from a client to the server which in return sends a command back to itself. So from a client to the server which in return sends a command back to itself. So
now you can display a message in the current client by calling the following in now you can display a message in the current client by calling the following in
@@ -292,63 +292,55 @@ a shell command:
lf -remote "send $id echo hello world" lf -remote "send $id echo hello world"
A common use for this feature is to display an error message back in the Since lf does not have control flow syntax, remote commands are used for such
client. You can implement a safe rename command which does not overwrite an needs. A common use is to display an error message back in the client. You can
existing file or directory as such: implement a safe rename command which does not overwrite an existing file or
directory as such:
cmd rename ${{ cmd rename ${{
if [ -e "$1" ]; then if [ -e $1 ]; then
lf -remote "send $id echo file exists" lf -remote "send $id echo file exists"
else else
mv "$f" "$1" mv $f $1
fi fi
}} }}
Since lf does not have control flow syntax, remote commands are used for such Besides 'send' command, there are also two commands to get or set the current
needs. Following example can be used to dynamically set the number of columns file selection. Two possible modes 'copy' and 'move' specify whether selected
on startup based on terminal width: files are to be copied or moved. File names are separated by newline character.
Setting the file selection is done with 'save' command:
${{ nc -U /tmp/lf.${USER}.sock << 'EOF'
w=$(tput cols) save
if [ $w -le 80 ]; then copy
lf -remote "send $id set ratios 1:2" foo.txt
elif [ $w -le 160 ]; then bar.txt
lf -remote "send $id set ratios 1:2:3" baz.txt
else
lf -remote "send $id set ratios 1:2:3:5"
fi
}}
Besides "send" command, there are also two commands to get or set the current EOF
file selection. Two possible modes "copy" and "move" specify whether selected
files are to be copied or moved. File names are separated ":" character.
Setting the file selection is done with "save" command:
lf -remote 'save copy foo.txt:bar.txt:baz.txt' Getting the file selection is similarly done with 'load' command:
Getting the file selection is similarly done with "load" command. You may need
to parse the response as such to achieve what you need:
resp=$(echo 'load' | nc -U /tmp/lf.${USER}.sock) resp=$(echo 'load' | nc -U /tmp/lf.${USER}.sock)
mode=$(echo $resp | cut -d' ' -f1) mode=$(echo "$resp" | sed -n '1p')
list=$(echo $resp | cut -d' ' -f2-) list=$(echo "$resp" | sed '1d')
if [ $mode = 'copy' ]; then if [ $mode = 'copy' ]; then
# do something with the $list # do something with $list
elif [ $mode = 'move' ]; then elif [ $mode = 'move' ]; then
# do something else with the $list # do something else with $list
fi fi
Lastly, there is a "conn" command to connect the server as a client. This Lastly, there is a 'conn' command to connect the server as a client. This
should not be needed for users. should not be needed for users.
File Operations File Operations
lf uses the underlying "cp" and "mv" shell commands for file operations. For lf uses the underlying 'cp' and 'mv' shell commands for file operations. For
this purpose, when you "yank" (i.e. copy) a file, it doesn't actually copy the this purpose, when you 'yank' (i.e. copy) a file, it doesn't actually copy the
file on the disk, but only records its name to memory. The actual file file on the disk, but only records its name to memory. The actual file
operation takes place when you do the "put" in which case the "cp" command is operation takes place when you do the 'put' in which case the 'cp' command is
used. Similarly the "mv" command is used for "delete" (i.e. cut or kill) used. Similarly the 'mv' command is used for 'delete' (i.e. cut or kill)
followed by "put". These traditional names (e.g. "yank", "delete", and "put") followed by 'put'. These traditional names (e.g. 'yank', 'delete', and 'put')
are picked instead of the other common convention (e.g. copy and cut) to are picked instead of the other common convention (e.g. copy and cut) to
resemble the default keybinds for these operations. resemble the default keybinds for these operations.
@@ -359,31 +351,31 @@ completely are provided in the example configuration file.
Opening Files Opening Files
You can use "open-file" command to open a file. This is a special command 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 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 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: desired. You can define it just as you would define any other command:
cmd open-file $vim $fx cmd open-file $vi $fx
It is possible to use different command types: It is possible to use different command types:
cmd open-file &xdg-open $f cmd open-file &xdg-open $f
You may want to use either file extensions or mime types from "file" command: You may want to use either file extensions or mime types from 'file' command:
cmd open-file ${{ cmd open-file ${{
case $(file --mime-type $f -b) in case $(file --mime-type $f -b) in
text/*) vim $fx;; text/*) vi $fx;;
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
esac esac
}} }}
lf does not come bundled with a file opener. You can use any of the existing lf does not come bundled with a file opener. You can use any of the existing
file openers as you like. Possible options are "open" (for Mac OS X only), file openers as you like. Possible options are 'open' (for Mac OS X only),
"xdg-utils" (executable name is "xdg-open"), "libfile-mimeinfo-perl" 'xdg-utils' (executable name is 'xdg-open'), 'libfile-mimeinfo-perl'
(executable name is "mimeopen"), "rifle" (ranger's default file opener), or (executable name is 'mimeopen'), 'rifle' (ranger's default file opener), or
"mimeo" to name a few. 'mimeo' to name a few.
Previewing Files Previewing Files
@@ -393,7 +385,7 @@ preview script for filtering. This can be used to highlight source codes, list
contents of archive files or view pdf or image files as text to name few. For contents of archive files or view pdf or image files as text to name few. For
coloring lf recognizes ansi escape codes. coloring lf recognizes ansi escape codes.
In order to use this feature you need to set the value of "previewer" option to In order to use this feature you need to set the value of 'previewer' option to
the path of an executable file. lf passes the current file name as the first the path of an executable file. lf passes the current file name as the first
argument and the height of the preview pane as the second argument when running argument and the height of the preview pane as the second argument when running
this file. Output of the execution is printed in the preview pane. You may want this file. Output of the execution is printed in the preview pane. You may want
@@ -405,7 +397,7 @@ to use the same script in your pager mapping as well if any:
Since this script is called for each file selection change it needs to be as Since this script is called for each file selection change it needs to be as
efficient as possible and this responsibility is left to the user. You may use efficient as possible and this responsibility is left to the user. You may use
file extensions to determine the type of file more efficiently compared to file extensions to determine the type of file more efficiently compared to
obtaining mime types from "file" command. Extensions can then be used to match obtaining mime types from 'file' command. Extensions can then be used to match
cleanly within a conditional: cleanly within a conditional:
#!/bin/sh #!/bin/sh
@@ -420,8 +412,8 @@ cleanly within a conditional:
esac esac
Another important consideration for efficiency is the use of programs with Another important consideration for efficiency is the use of programs with
short startup times for preview. For this reason, "highlight" is recommended short startup times for preview. For this reason, 'highlight' is recommended
over "pygmentize" for syntax highlighting. Besides, it is also important that over 'pygmentize' for syntax highlighting. Besides, it is also important that
the application is processing the file on the fly rather than first reading it the application is processing the file on the fly rather than first reading it
to the memory and then do the processing afterwards. This is especially to the memory and then do the processing afterwards. This is especially
relevant for big files. lf automatically closes the previewer script output relevant for big files. lf automatically closes the previewer script output
+8 -22
View File
@@ -119,7 +119,7 @@ Prefixes
The following command prefixes are used by lf: The following command prefixes are used by lf:
: read (default) built-in command : read (default) builtin/custom command
$ read-shell shell command $ read-shell shell command
! read-shell-wait shell command waiting for key press ! read-shell-wait shell command waiting for key press
& read-shell-async asynchronous shell command & read-shell-async asynchronous shell command
@@ -151,16 +151,16 @@ variants for configuration.
set sortby 'time' # string value with single quotes (whitespaces) set sortby 'time' # string value with single quotes (whitespaces)
set sortby "time" # string value with double quotes (backslash escapes) set sortby "time" # string value with double quotes (backslash escapes)
"map" is used to bind a key to a command which can be built-in command, "map" is used to bind a key to a command which can be builtin command,
custom command, or shell command: custom command, or shell command:
map gh cd ~ # built-in command map gh cd ~ # builtin command
map D trash # custom command map D trash # custom command
map i $less "$f" # shell command map i $less "$f" # shell command
map u !du -h . # waiting shell command map u !du -h . # waiting shell command
"cmap" is used to bind a key to a command line command which can only be one "cmap" is used to bind a key to a command line command which can only be one
of the built-in commands: of the builtin commands:
cmap <c-g> cmd-escape cmap <c-g> cmd-escape
@@ -305,9 +305,10 @@ calling the following in a shell command:
lf -remote "send $id echo hello world" lf -remote "send $id echo hello world"
A common use for this feature is to display an error message back in the Since lf does not have control flow syntax, remote commands are used for
client. You can implement a safe rename command which does not overwrite an such needs. A common use is to display an error message back in the client.
existing file or directory as such: You can implement a safe rename command which does not overwrite an existing
file or directory as such:
cmd rename ${{ cmd rename ${{
if [ -e "$1" ]; then if [ -e "$1" ]; then
@@ -317,21 +318,6 @@ existing file or directory as such:
fi fi
}} }}
Since lf does not have control flow syntax, remote commands are used for
such needs. Following example can be used to dynamically set the number of
columns on startup based on terminal width:
${{
w=$(tput cols)
if [ $w -le 80 ]; then
lf -remote "send $id set ratios 1:2"
elif [ $w -le 160 ]; then
lf -remote "send $id set ratios 1:2:3"
else
lf -remote "send $id set ratios 1:2:3:5"
fi
}}
Besides "send" command, there are also two commands to get or set the Besides "send" command, there are also two commands to get or set the
current file selection. Two possible modes "copy" and "move" specify whether current file selection. Two possible modes "copy" and "move" specify whether
selected files are to be copied or moved. File names are separated ":" selected files are to be copied or moved. File names are separated ":"
+18 -18
View File
@@ -1,9 +1,9 @@
# interpreter for shell commands (needs to be POSIX compatible) # interpreter for shell commands (needs to be POSIX compatible)
#set shell /bin/sh set shell /bin/sh
# set internal field separator (IFS) to "\n" for shell commands # set internal field separator (IFS) to "\n" for shell commands
# This is useful to automatically split file names in $fs and $fx properly # This is useful to automatically split file names in $fs and $fx properly
# since default file separator used in these variables (i.e. `filesep` option) # since default file separator used in these variables (i.e. 'filesep' option)
# is newline. You need to consider the values of these options and create your # is newline. You need to consider the values of these options and create your
# commands accordingly. # commands accordingly.
set ifs "\n" set ifs "\n"
@@ -11,11 +11,11 @@ set ifs "\n"
# leave some space at the top and the bottom of the screen # leave some space at the top and the bottom of the screen
set scrolloff 10 set scrolloff 10
# easily toggle options # toggle options
map zp set preview! map zp set preview!
map zh set hidden! map zh set hidden!
# easily select what information to show # select what information to show
map zn set info map zn set info
map zs set info size map zs set info size
map zt set info time map zt set info time
@@ -35,7 +35,7 @@ map <enter> read-shell
# mappings for pager and editor (change as you like) # mappings for pager and editor (change as you like)
map i $less $f map i $less $f
map e $vim $f map e $vi $f
# mapping to spawn a shell in working directory # mapping to spawn a shell in working directory
# (see also etc/lf.sh as an alternative workflow) # (see also etc/lf.sh as an alternative workflow)
@@ -49,16 +49,16 @@ map X !$f
map o &mimeopen $f map o &mimeopen $f
map O $mimeopen --ask $f map O $mimeopen --ask $f
# show documentation (overrides search-back) # show documentation (overrides 'search-back' command)
map ? $lf -doc | less map ? $lf -doc | less
# define a custom `open-file` command # define a custom 'open-file' command
# `open-file` is called by `open` when current file is not a directory. You may # '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 # 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. # editor for text files and a file opener for the rest.
cmd open-file ${{ cmd open-file ${{
case $(file --mime-type $f -b) in case $(file --mime-type $f -b) in
text/*) vim $fx;; text/*) vi $fx;;
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
esac esac
}} }}
@@ -77,19 +77,19 @@ map r push :rename<space>
cmd usage $du -h . | less cmd usage $du -h . | less
# make sure trash folder exists # make sure trash folder exists
$mkdir -p $HOME/.trash $mkdir -p ~/.trash
# move current file or selected files to trash folder # move current file or selected files to trash folder
# (see 'man mv' or 'mv --help' for backup options) # (see 'man mv' or 'mv --help' for backup options)
cmd trash $mv --backup=numbered $fx $HOME/.trash cmd trash $mv --backup=numbered $fx ~/.trash
# remove current file or selected files (prompting) # remove current file or selected files (prompting)
#cmd remove ${{ cmd remove ${{
# printf "$fx\n" printf "$fx\n"
# printf "remove?[y/n]" printf "remove?[y/n]"
# read ans read ans
# [ $ans = "y" ] && rm -rf $fx [ $ans = "y" ] && rm -rf $fx
#}} }}
# extract the current file with the right command # extract the current file with the right command
# (xkcd link: https://xkcd.com/1168/) # (xkcd link: https://xkcd.com/1168/)
@@ -106,7 +106,7 @@ cmd extract ${{
# compress marked files with tar and gunzip # compress marked files with tar and gunzip
# This command takes the output name without '.tar.gz' suffix as an argument # This command takes the output name without '.tar.gz' suffix as an argument
# (e.g. "compress foo" creates "foo.tar.gz"). # (e.g. 'compress foo' creates 'foo.tar.gz').
cmd compress ${{ cmd compress ${{
mkdir $1 mkdir $1
cp $fs $1 cp $fs $1