cleanup
This commit is contained in:
parent
f9382f72d4
commit
6f525ba047
416
doc.go
416
doc.go
@ -722,10 +722,10 @@ The following command prefixes are used by lf:
|
|||||||
! shell-wait shell command waiting for key press
|
! shell-wait shell command waiting for key press
|
||||||
& shell-async shell command running asynchronously
|
& shell-async shell command running asynchronously
|
||||||
|
|
||||||
The same evaluator is used for the command line and the configuration file for
|
The same evaluator is used for the command line and the configuration file for read and shell commands.
|
||||||
read and shell commands. The difference is that prefixes are not necessary in
|
The difference is that prefixes are not necessary in the command line.
|
||||||
the command line. Instead, different modes are provided to read corresponding
|
Instead, different modes are provided to read corresponding commands.
|
||||||
commands. These modes are mapped to the prefix keys above by default.
|
These modes are mapped to the prefix keys above by default.
|
||||||
|
|
||||||
Syntax
|
Syntax
|
||||||
|
|
||||||
@ -733,11 +733,9 @@ 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.
|
|
||||||
|
|
||||||
Command 'set' is used to set an option which can be boolean, integer, or
|
Command 'set' is used to set an option which can be boolean, integer, or string:
|
||||||
string:
|
|
||||||
|
|
||||||
set hidden # boolean on
|
set hidden # boolean on
|
||||||
set nohidden # boolean off
|
set nohidden # boolean off
|
||||||
@ -747,16 +745,14 @@ string:
|
|||||||
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)
|
||||||
|
|
||||||
Command 'map' is used to bind a key to a command which can be builtin command,
|
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 ~ # builtin 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 -sh # waiting shell command
|
map U !du -sh # waiting shell command
|
||||||
|
|
||||||
Command 'cmap' is used to bind a key to a command line command which can only
|
Command 'cmap' is used to bind a key to a command line command which can only be one of the builtin commands:
|
||||||
be one of the builtin commands:
|
|
||||||
|
|
||||||
cmap <c-g> cmd-escape
|
cmap <c-g> cmd-escape
|
||||||
|
|
||||||
@ -777,13 +773,11 @@ 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 newline which is
|
An explicit ':' can be provided to group statements until a newline which 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 :{{
|
||||||
set sortby time
|
set sortby time
|
||||||
@ -800,8 +794,7 @@ Keys combined with the shift key simply use the uppercase letter:
|
|||||||
|
|
||||||
map A down
|
map A down
|
||||||
|
|
||||||
Special keys are written in between '<' and '>' characters and always use
|
Special keys are written in between '<' and '>' characters and always use lowercase letters:
|
||||||
lowercase letters:
|
|
||||||
|
|
||||||
map <enter> down
|
map <enter> down
|
||||||
|
|
||||||
@ -818,36 +811,31 @@ Keys combined with the control key are prefixed with 'c' character:
|
|||||||
|
|
||||||
map <c-a> down
|
map <c-a> down
|
||||||
|
|
||||||
Keys combined with the alt key are assigned in two different ways depending on
|
Keys combined with the alt key are assigned in two different ways depending on the behavior of your terminal.
|
||||||
the behavior of your terminal. Older terminals (e.g. xterm) may set the 8th bit
|
Older terminals (e.g. xterm) may set the 8th bit of a character when the alt key is pressed.
|
||||||
of a character when the alt key is pressed. On these terminals, you can use the
|
On these terminals, you can use the corresponding byte for the mapping:
|
||||||
corresponding byte for the mapping:
|
|
||||||
|
|
||||||
map á down
|
map á down
|
||||||
|
|
||||||
Newer terminals (e.g. gnome-terminal) may prefix the key with an escape key
|
Newer terminals (e.g. gnome-terminal) may prefix the key with an escape key when the alt key is pressed.
|
||||||
when the alt key is pressed. lf uses the escape delaying mechanism to recognize
|
lf uses the escape delaying mechanism to recognize alt keys in these terminals (delay is 100ms).
|
||||||
alt keys in these terminals (delay is 100ms). On these terminals, keys combined
|
On these terminals, keys combined with the alt key are prefixed with 'a' character:
|
||||||
with the alt key are prefixed with 'a' character:
|
|
||||||
|
|
||||||
map <a-a> down
|
map <a-a> down
|
||||||
|
|
||||||
Please note that, some key combinations are not possible due to the way
|
Please note that, some key combinations are not possible due to the way terminals work (e.g. control and h combination sends a backspace key instead).
|
||||||
terminals work (e.g. control and h combination sends a backspace key instead).
|
The easiest way to find the name of a key combination is to press the key while lf is running and read the name of the key from the unknown mapping error.
|
||||||
The easiest way to find the name of a key combination is to press the key while
|
|
||||||
lf is running and read the name of the key from the unknown mapping error.
|
|
||||||
|
|
||||||
Push Mappings
|
Push 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.
|
||||||
command. While this provides a clean way to remap builtin keys as well as other
|
While this provides a clean way to remap builtin keys as well as other commands, it can be limiting at times.
|
||||||
commands, it can be limiting at times. For this reason 'push' command is
|
For this reason 'push' command is provided by lf.
|
||||||
provided by lf. This command is used to simulate key pushes given as its
|
This command is used to simulate key pushes given as its arguments.
|
||||||
arguments. You can 'map' a key to a 'push' command with an argument to create
|
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.
|
||||||
with a command count:
|
First, it can be used to map a command with a command count:
|
||||||
|
|
||||||
map <c-j> push 10j
|
map <c-j> push 10j
|
||||||
|
|
||||||
@ -855,8 +843,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
|
||||||
|
|
||||||
@ -864,9 +851,9 @@ These types of bindings create a deadlock when executed.
|
|||||||
|
|
||||||
Shell Commands
|
Shell Commands
|
||||||
|
|
||||||
Regular shell commands are the most basic command type that is useful for many
|
Regular shell commands are the most basic command type that is useful for many purposes.
|
||||||
purposes. For example, we can write a shell command to move selected file(s) to
|
For example, we can write a shell command to move selected file(s) to trash.
|
||||||
trash. A first attempt to write such a command may look like this:
|
A first attempt to write such a command may look like this:
|
||||||
|
|
||||||
cmd trash ${{
|
cmd trash ${{
|
||||||
mkdir -p ~/.trash
|
mkdir -p ~/.trash
|
||||||
@ -877,17 +864,18 @@ trash. A first attempt to write such a command may look like this:
|
|||||||
fi
|
fi
|
||||||
}}
|
}}
|
||||||
|
|
||||||
We check '$fs' to see if there are any selected files. Otherwise we just delete
|
We check '$fs' to see if there are any selected files.
|
||||||
the current file. Since this is such a common pattern, a separate '$fx'
|
Otherwise we just delete the current file.
|
||||||
variable is provided. We can use this variable to get rid of the conditional:
|
Since this is such a common pattern, a separate '$fx' variable is provided.
|
||||||
|
We can use this variable to get rid of the conditional:
|
||||||
|
|
||||||
cmd trash ${{
|
cmd trash ${{
|
||||||
mkdir -p ~/.trash
|
mkdir -p ~/.trash
|
||||||
IFS="`printf '\n\t'`"; mv $fx ~/.trash
|
IFS="`printf '\n\t'`"; mv $fx ~/.trash
|
||||||
}}
|
}}
|
||||||
|
|
||||||
The trash directory is checked each time the command is executed. We can move
|
The trash directory is checked each time the command is executed.
|
||||||
it outside of the command so it would only run once at startup:
|
We can move it outside of the command so it would only run once at startup:
|
||||||
|
|
||||||
${{ mkdir -p ~/.trash }}
|
${{ mkdir -p ~/.trash }}
|
||||||
|
|
||||||
@ -899,92 +887,77 @@ Since these are one liners, we can drop '{{' and '}}':
|
|||||||
|
|
||||||
cmd trash $IFS="`printf '\n\t'`"; mv $fx ~/.trash
|
cmd trash $IFS="`printf '\n\t'`"; mv $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.
|
||||||
could use the 'ifs' option to set it for all shell commands (i.e. 'set ifs
|
Instead we could use the 'ifs' option to set it for all shell commands (i.e. 'set ifs "\n"').
|
||||||
"\n"'). This can be especially useful for interactive use (e.g. '$rm $f' or
|
This can be especially useful for interactive use (e.g. '$rm $f' or '$rm $fs' would simply work).
|
||||||
'$rm $fs' would simply work). This option is not set by default as it can
|
This option is not set by default as it can behave unexpectedly for new users.
|
||||||
behave unexpectedly for new users. However, use of this option is highly
|
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.
|
|
||||||
|
|
||||||
Piping Shell Commands
|
Piping Shell Commands
|
||||||
|
|
||||||
Regular shell commands have some limitations in some cases. When an output or
|
Regular shell commands have some limitations in some cases.
|
||||||
error message is given and the command exits afterwards, the ui is immediately
|
When an output or error message is given and the command exits afterwards, the ui is immediately resumed and there is no way to see the message without dropping to shell again.
|
||||||
resumed and there is no way to see the message without dropping to shell again.
|
Also, even when there is no output or error, the ui still needs to be paused while the command is running.
|
||||||
Also, even when there is no output or error, the ui still needs to be paused
|
This can cause flickering on the screen for short commands and similar distractions for longer commands.
|
||||||
while the command is running. This can cause flickering on the screen for short
|
|
||||||
commands and similar distractions for longer commands.
|
|
||||||
|
|
||||||
Instead of pausing the ui, piping shell commands connects stdin, stdout, and
|
Instead of pausing the ui, piping shell commands connects stdin, stdout, and stderr of the command to the statline in the bottom of the ui.
|
||||||
stderr of the command to the statline in the bottom of the ui. This can be
|
This can be useful for programs following the unix philosophy to give no output in the success case, and brief error messages or prompts in other cases.
|
||||||
useful for programs following the unix philosophy to give no output in the
|
|
||||||
success case, and brief error messages or prompts in other cases.
|
|
||||||
|
|
||||||
For example, following rename command prompts for overwrite in the statline if
|
For example, following rename command prompts for overwrite in the statline if there is an existing file with the given name:
|
||||||
there is an existing file with the given name:
|
|
||||||
|
|
||||||
cmd rename %mv -i $f $1
|
cmd rename %mv -i $f $1
|
||||||
|
|
||||||
You can also output error messages in the command and it will show up in the
|
You can also output error messages in the command and it will show up in the statline.
|
||||||
statline. For example, an alternative rename command may look like this:
|
For example, an alternative rename command may look like this:
|
||||||
|
|
||||||
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
||||||
|
|
||||||
One thing to be careful is that although input is still line buffered, output
|
One thing to be careful is that although input is still line buffered, output and error are byte buffered and verbose commands will be very slow to display.
|
||||||
and error are byte buffered and verbose commands will be very slow to display.
|
|
||||||
|
|
||||||
Waiting Shell Commands
|
Waiting Shell Commands
|
||||||
|
|
||||||
Waiting shell commands are similar to regular shell commands except that they
|
Waiting shell commands are similar to regular shell commands except that they wait for a key press when the command is finished.
|
||||||
wait for a key press when the command is finished. These can be useful to see
|
These can be useful to see the output of a program before the ui is resumed.
|
||||||
the output of a program before the ui is resumed. Waiting shell commands are
|
Waiting shell commands are more appropriate than piping shell commands when the command is verbose and the output is best displayed as multiline.
|
||||||
more appropriate than piping shell commands when the command is verbose and the
|
|
||||||
output is best displayed as multiline.
|
|
||||||
|
|
||||||
Asynchronous Shell Commands
|
Asynchronous Shell Commands
|
||||||
|
|
||||||
Asynchronous shell commands are used to start a command in the background and
|
Asynchronous shell commands are used to start a command in the background and then resume operation without waiting for the command to finish.
|
||||||
then resume operation without waiting for the command to finish. Stdin, stdout,
|
Stdin, stdout, and stderr of the command is neither connected to the terminal nor to the ui.
|
||||||
and stderr of the command is neither connected to the terminal nor to the ui.
|
|
||||||
|
|
||||||
Remote Commands
|
Remote Commands
|
||||||
|
|
||||||
One of the more advanced features in lf is remote commands. All clients connect
|
One of the more advanced features in lf is remote commands.
|
||||||
to a server on startup. It is possible to send commands to all or any of the
|
All clients connect to a server on startup.
|
||||||
connected clients over the common server. This is used internally to notify
|
It is possible to send commands to all or any of the connected clients over the common server.
|
||||||
file selection changes to other clients.
|
This is used internally to notify file selection changes to other clients.
|
||||||
|
|
||||||
To use this feature, you need to use a client which supports communicating with
|
To use this feature, you need to use a client which supports communicating with a UNIX-domain socket.
|
||||||
a UNIX-domain socket. OpenBSD implementation of netcat (nc) is one such
|
OpenBSD implementation of netcat (nc) is one such example.
|
||||||
example. You can use it to send a command to the socket file:
|
You can use it to send a command to the socket file:
|
||||||
|
|
||||||
echo 'send echo hello world' | nc -U /tmp/lf.${USER}.sock
|
echo 'send echo hello world' | nc -U /tmp/lf.${USER}.sock
|
||||||
|
|
||||||
Since such a client may not be available everywhere, lf comes bundled with a
|
Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such.
|
||||||
command line flag to be used as such. When using lf, you do not need to specify
|
When using lf, you do not need to specify the address of the socket file.
|
||||||
the address of the socket file. This is the recommended way of using remote
|
This is the recommended way of using remote commands since it is shorter and immune to socket file address changes:
|
||||||
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.
|
||||||
all connected clients. You can optionally give it an id number to send a
|
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.
|
||||||
when you are writing a command. For this purpose, an '$id' variable is exported
|
For this purpose, an '$id' variable is exported to the environment for shell commands.
|
||||||
to the environment for shell commands. You can use it to send a remote command
|
You can use it to send a remote command from a client to the server which in return sends a command back to itself.
|
||||||
from a client to the server which in return sends a command back to itself. So
|
So now you can display a message in the current client by calling the following in a shell command:
|
||||||
now you can display a message in the current client by calling the following in
|
|
||||||
a shell command:
|
|
||||||
|
|
||||||
lf -remote "send $id echo hello world"
|
lf -remote "send $id echo hello world"
|
||||||
|
|
||||||
Since lf does not have control flow syntax, remote commands are used for such
|
Since lf does not have control flow syntax, remote commands are used for such needs.
|
||||||
needs. For example, you can configure the number of columns in the ui with
|
For example, you can configure the number of columns in the ui with respect to the terminal width as follows:
|
||||||
respect to the terminal width as follows:
|
|
||||||
|
|
||||||
cmd recol %{{
|
cmd recol %{{
|
||||||
w=$(tput cols)
|
w=$(tput cols)
|
||||||
@ -997,9 +970,9 @@ respect to the terminal width as follows:
|
|||||||
fi
|
fi
|
||||||
}}
|
}}
|
||||||
|
|
||||||
Besides 'send' command, there are also two commands to get or set the current
|
Besides 'send' command, there are also two commands to get or set the current file selection.
|
||||||
file selection. Two possible modes 'copy' and 'move' specify whether selected
|
Two possible modes 'copy' and 'move' specify whether selected files are to be copied or moved.
|
||||||
files are to be copied or moved. File names are separated by newline character.
|
File names are separated by newline character.
|
||||||
Setting the file selection is done with 'save' command:
|
Setting the file selection is done with 'save' command:
|
||||||
|
|
||||||
lf -remote "$(printf 'save\ncopy\nfoo.txt\nbar.txt\nbaz.txt\n')"
|
lf -remote "$(printf 'save\ncopy\nfoo.txt\nbar.txt\nbaz.txt\n')"
|
||||||
@ -1019,33 +992,29 @@ There is a 'quit' command to close client connections and quit the server:
|
|||||||
|
|
||||||
lf -remote 'quit'
|
lf -remote 'quit'
|
||||||
|
|
||||||
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.
|
||||||
should not be needed for users.
|
This should not be needed for users.
|
||||||
|
|
||||||
File Operations
|
File Operations
|
||||||
|
|
||||||
lf uses its own builtin copy and move operations by default. These are
|
lf uses its own builtin copy and move operations by default.
|
||||||
implemented as asynchronous operations and progress is shown in the bottom
|
These are implemented as asynchronous operations and progress is shown in the bottom ruler.
|
||||||
ruler. These commands do not overwrite existing files or directories with the
|
These commands do not overwrite existing files or directories with the same name.
|
||||||
same name. Instead, a suffix that is compatible with '--backup=numbered' option
|
Instead, a suffix that is compatible with '--backup=numbered' option in GNU cp is added to the new files or directories.
|
||||||
in GNU cp is added to the new files or directories. Only file modes are
|
Only file modes are preserved and all other attributes are ignored including ownership, timestamps, context, links, and xattr.
|
||||||
preserved and all other attributes are ignored including ownership, timestamps,
|
Special files such as character and block devices, named pipes, and sockets are skipped and links are followed.
|
||||||
context, links, and xattr. Special files such as character and block devices,
|
Moving is performed using the rename operation of the underlying OS.
|
||||||
named pipes, and sockets are skipped and links are followed. Moving is
|
For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors.
|
||||||
performed using the rename operation of the underlying OS. For cross-device
|
Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation.
|
||||||
moving, lf falls back to copying and then deletes the original files if there
|
|
||||||
are no errors. Operation errors are shown in the message line as well as the
|
|
||||||
log file and they do not preemptively finish the corresponding file operation.
|
|
||||||
|
|
||||||
File operations can be performed on the current selected file or alternatively
|
File operations can be performed on the current selected file or alternatively on multiple files by selecting them first.
|
||||||
on multiple files by selecting them first. When you 'copy' a file, lf doesn't
|
When you 'copy' a file, lf doesn't actually copy the file on the disk, but only records its name to memory.
|
||||||
actually copy the file on the disk, but only records its name to memory. The
|
The actual file copying takes place when you 'paste'.
|
||||||
actual file copying takes place when you 'paste'. Similarly 'paste' after a
|
Similarly 'paste' after a 'cut' operation moves the file.
|
||||||
'cut' operation moves the file.
|
|
||||||
|
|
||||||
You can customize copy and move operations by defining a 'paste' command. This
|
You can customize copy and move operations by defining a 'paste' command.
|
||||||
is a special command that is called when it is defined instead of the builtin
|
This is a special command that is called when it is defined instead of the builtin implementation.
|
||||||
implementation. You can use the following example as a starting point:
|
You can use the following example as a starting point:
|
||||||
|
|
||||||
cmd paste %{{
|
cmd paste %{{
|
||||||
load=$(lf -remote 'load')
|
load=$(lf -remote 'load')
|
||||||
@ -1060,65 +1029,51 @@ implementation. You can use the following example as a starting point:
|
|||||||
lf -remote 'send clear'
|
lf -remote 'send clear'
|
||||||
}}
|
}}
|
||||||
|
|
||||||
Some useful things to be considered are to use the backup ('--backup') and/or
|
Some useful things to be considered are to use the backup ('--backup') and/or preserve attributes ('-a') options with 'cp' and 'mv' commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use 'rsync' command with progress bar option for copying and feed the progress to the client periodically with remote 'echo' calls.
|
||||||
preserve attributes ('-a') options with 'cp' and 'mv' commands if they support
|
|
||||||
it (i.e. GNU implementation), change the command type to asynchronous, or use
|
|
||||||
'rsync' command with progress bar option for copying and feed the progress to
|
|
||||||
the client periodically with remote 'echo' calls.
|
|
||||||
|
|
||||||
By default, lf does not assign 'delete' command to a key to protect new users.
|
By default, lf does not assign 'delete' command to a key to protect new users.
|
||||||
You can customize file deletion by defining a 'delete' command. You can also
|
You can customize file deletion by defining a 'delete' command.
|
||||||
assign a key to this command if you like. An example command to move selected
|
You can also assign a key to this command if you like.
|
||||||
files to a trash folder and remove files completely after a prompt are provided
|
An example command to move selected files to a trash folder and remove files completely after a prompt are provided in the example configuration file.
|
||||||
in the example configuration file.
|
|
||||||
|
|
||||||
Searching Files
|
Searching Files
|
||||||
|
|
||||||
There are two mechanisms implemented in lf to search a file in the current
|
There are two mechanisms implemented in lf to search a file in the current directory.
|
||||||
directory. Searching is the traditional method to move the selection to a file
|
Searching is the traditional method to move the selection to a file matching a given pattern.
|
||||||
matching a given pattern. Finding is an alternative way to search for a pattern
|
Finding is an alternative way to search for a pattern possibly using fewer keystrokes.
|
||||||
possibly using fewer keystrokes.
|
|
||||||
|
|
||||||
Searching mechanism is implemented with commands 'search' (default '/'),
|
Searching mechanism is implemented with commands 'search' (default '/'), 'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev' (default 'N').
|
||||||
'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev'
|
You can enable 'globsearch' option to match with a glob pattern.
|
||||||
(default 'N'). You can enable 'globsearch' option to match with a glob pattern.
|
Globbing supports '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges.
|
||||||
Globbing supports '*' to match any sequence, '?' to match any character, and
|
You can enable 'incsearch' option to jump to the current match at each keystroke while typing.
|
||||||
'[...]' or '[^...] to match character sets or ranges. You can enable
|
In this mode, you can either use 'cmd-enter' to accept the search or use 'cmd-escape' to cancel the search.
|
||||||
'incsearch' option to jump to the current match at each keystroke while typing.
|
Alternatively, you can also map some other commands with 'cmap' to accept the search and execute the command immediately afterwards.
|
||||||
In this mode, you can either use 'cmd-enter' to accept the search or use
|
Possible candidates are 'up', 'down' and their variants, 'updir', and 'open' commands.
|
||||||
'cmd-escape' to cancel the search. Alternatively, you can also map some other
|
For example, you can use arrow keys to finish the search with the following mappings:
|
||||||
commands with 'cmap' to accept the search and execute the command immediately
|
|
||||||
afterwards. Possible candidates are 'up', 'down' and their variants, 'updir',
|
|
||||||
and 'open' commands. For example, you can use arrow keys to finish the search
|
|
||||||
with the following mappings:
|
|
||||||
|
|
||||||
cmap <up> up
|
cmap <up> up
|
||||||
cmap <down> down
|
cmap <down> down
|
||||||
cmap <left> updir
|
cmap <left> updir
|
||||||
cmap <right> open
|
cmap <right> open
|
||||||
|
|
||||||
Finding mechanism is implemented with commands 'find' (default 'f'),
|
Finding mechanism is implemented with commands 'find' (default 'f'), 'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default ',').
|
||||||
'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default
|
You can disable 'anchorfind' option to match a pattern at an arbitrary position in the filename instead of the beginning.
|
||||||
','). You can disable 'anchorfind' option to match a pattern at an arbitrary
|
You can set the number of keys to match using 'findlen' option.
|
||||||
position in the filename instead of the beginning. You can set the number of
|
If you set this value to zero, then the the keys are read until there is only a single match.
|
||||||
keys to match using 'findlen' option. If you set this value to zero, then the
|
Default values of these two options are set to jump to the first file with the given initial.
|
||||||
the keys are read until there is only a single match. Default values of these
|
|
||||||
two options are set to jump to the first file with the given initial.
|
|
||||||
|
|
||||||
Some options effect both searching and finding. You can disable 'wrapscan'
|
Some options effect both searching and finding.
|
||||||
option to prevent searches to wrap around at the end of the file list. You can
|
You can disable 'wrapscan' option to prevent searches to wrap around at the end of the file list.
|
||||||
disable 'ignorecase' option to match cases in the pattern and the filename.
|
You can disable 'ignorecase' option to match cases in the pattern and the filename.
|
||||||
This option is already automatically overridden if the pattern contains upper
|
This option is already automatically overridden if the pattern contains upper case characters.
|
||||||
case characters. You can disable 'smartcase' option to disable this behavior.
|
You can disable 'smartcase' option to disable this behavior.
|
||||||
Two similar options 'ignoredia' and 'smartdia' are provided to control matching
|
Two similar options 'ignoredia' and 'smartdia' are provided to control matching diacritics in latin letters.
|
||||||
diacritics in latin letters.
|
|
||||||
|
|
||||||
Opening Files
|
Opening Files
|
||||||
|
|
||||||
You can define a an 'open' command (default 'l' and '<right>') to configure
|
You can define a an 'open' command (default 'l' and '<right>') to configure file opening.
|
||||||
file opening. This command is only called when the current file is not a
|
This command is only called when the current file is not a directory, otherwise the directory is entered instead.
|
||||||
directory, otherwise the directory is entered instead. You can define it just
|
You can define it just as you would define any other command:
|
||||||
as you would define any other command:
|
|
||||||
|
|
||||||
cmd open $vi $fx
|
cmd open $vi $fx
|
||||||
|
|
||||||
@ -1135,39 +1090,33 @@ You may want to use either file extensions or mime types from 'file' command:
|
|||||||
esac
|
esac
|
||||||
}}
|
}}
|
||||||
|
|
||||||
You may want to use 'setsid' before your opener command to have persistent
|
You may want to use 'setsid' before your opener command to have persistent processes that continue to run after lf quits.
|
||||||
processes that continue to run after lf quits.
|
|
||||||
|
|
||||||
Following command is provided by default:
|
Following command is provided by default:
|
||||||
|
|
||||||
cmd open &$OPENER $f
|
cmd open &$OPENER $f
|
||||||
|
|
||||||
You may also use any other existing file openers as you like. Possible options
|
You may also use any other existing file openers as you like.
|
||||||
are 'libfile-mimeinfo-perl' (executable name is 'mimeopen'), 'rifle' (ranger's
|
Possible options are 'libfile-mimeinfo-perl' (executable name is 'mimeopen'), 'rifle' (ranger's default file opener), or 'mimeo' to name a few.
|
||||||
default file opener), or 'mimeo' to name a few.
|
|
||||||
|
|
||||||
Previewing Files
|
Previewing Files
|
||||||
|
|
||||||
lf previews files on the preview pane by printing the file until the end or the
|
lf previews files on the preview pane by printing the file until the end or the preview pane is filled.
|
||||||
preview pane is filled. This output can be enhanced by providing a custom
|
This output can be enhanced by providing a custom preview script for filtering.
|
||||||
preview script for filtering. This can be used to highlight source codes, list
|
This can be used to highlight source codes, list contents of archive files or view pdf or image files as text to name few.
|
||||||
contents of archive files or view pdf or image files as text to name few. For
|
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.
|
||||||
the path of an executable file. lf passes the current file name as the first
|
lf passes the current file name as the first argument and the height of the preview pane as the second argument when running this file.
|
||||||
argument and the height of the preview pane as the second argument when running
|
Output of the execution is printed in the preview pane.
|
||||||
this file. Output of the execution is printed in the preview pane. You may want
|
You may want to use the same script in your pager mapping as well if any:
|
||||||
to use the same script in your pager mapping as well if any:
|
|
||||||
|
|
||||||
set previewer ~/.config/lf/pv.sh
|
set previewer ~/.config/lf/pv.sh
|
||||||
map i $~/.config/lf/pv.sh $f | less -R
|
map i $~/.config/lf/pv.sh $f | less -R
|
||||||
|
|
||||||
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.
|
||||||
efficient as possible and this responsibility is left to the user. You may use
|
You may use file extensions to determine the type of file more efficiently compared to obtaining mime types from 'file' command.
|
||||||
file extensions to determine the type of file more efficiently compared to
|
Extensions can then be used to match cleanly within a conditional:
|
||||||
obtaining mime types from 'file' command. Extensions can then be used to match
|
|
||||||
cleanly within a conditional:
|
|
||||||
|
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
@ -1180,27 +1129,21 @@ cleanly within a conditional:
|
|||||||
*) highlight -O ansi "$1" || cat "$1";;
|
*) highlight -O ansi "$1" || cat "$1";;
|
||||||
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.
|
||||||
short startup times for preview. For this reason, 'highlight' is recommended
|
For this reason, 'highlight' is recommended over 'pygmentize' for syntax highlighting.
|
||||||
over 'pygmentize' for syntax highlighting. Besides, it is also important that
|
Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do the processing afterwards.
|
||||||
the application is processing the file on the fly rather than first reading it
|
This is especially relevant for big files.
|
||||||
to the memory and then do the processing afterwards. This is especially
|
lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read.
|
||||||
relevant for big files. lf automatically closes the previewer script output
|
When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview.
|
||||||
pipe with a SIGPIPE when enough lines are read. When everything else fails, you
|
|
||||||
can make use of the height argument to only feed the first portion of the file
|
|
||||||
to a program for preview.
|
|
||||||
|
|
||||||
Changing Directory
|
Changing Directory
|
||||||
|
|
||||||
lf changes the working directory of the process to the current directory so
|
lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory.
|
||||||
that shell commands always work in the displayed directory. After quitting, it
|
After quitting, it returns to the original directory where it is first launched like all shell programs.
|
||||||
returns to the original directory where it is first launched like all shell
|
If you want to stay in the current directory after quitting, you can use one of the example wrapper shell scripts provided in the repository.
|
||||||
programs. If you want to stay in the current directory after quitting, you can
|
|
||||||
use one of the example wrapper shell scripts provided in the repository.
|
|
||||||
|
|
||||||
There is a special command 'on-cd' that runs a shell command when it is defined
|
There is a special command 'on-cd' that runs a shell command when it is defined and the directory is changed.
|
||||||
and the directory is changed. You can define it just as you would define any
|
You can define it just as you would define any other command:
|
||||||
other command:
|
|
||||||
|
|
||||||
cmd on-cd &{{
|
cmd on-cd &{{
|
||||||
# display git repository status in your prompt
|
# display git repository status in your prompt
|
||||||
@ -1214,55 +1157,46 @@ other command:
|
|||||||
lf -remote "send $id set promptfmt \"$fmt\""
|
lf -remote "send $id set promptfmt \"$fmt\""
|
||||||
}}
|
}}
|
||||||
|
|
||||||
This command runs whenever you change directory but not on startup. You can add
|
This command runs whenever you change directory but not on startup.
|
||||||
an extra call to make it run on startup as well:
|
You can add an extra call to make it run on startup as well:
|
||||||
|
|
||||||
cmd on-cd &{{ # ... }}
|
cmd on-cd &{{ # ... }}
|
||||||
on-cd
|
on-cd
|
||||||
|
|
||||||
Note that all shell commands are possible but `%` and `&` are usually more
|
Note that all shell commands are possible but `%` and `&` are usually more appropriate as `$` and `!` causes flickers and pauses respectively.
|
||||||
appropriate as `$` and `!` causes flickers and pauses respectively.
|
|
||||||
|
|
||||||
Colorschemes
|
Colorschemes
|
||||||
|
|
||||||
lf tries to automatically adapt its colors to the environment. On startup,
|
lf tries to automatically adapt its colors to the environment.
|
||||||
first '$LS_COLORS' environment variable is checked. This variable is used by
|
On startup, first '$LS_COLORS' environment variable is checked.
|
||||||
GNU ls to configure its colors based on file types and extensions. The value of
|
This variable is used by GNU ls to configure its colors based on file types and extensions.
|
||||||
this variable is often set by GNU dircolors in a shell configuration file.
|
The value of this variable is often set by GNU dircolors in a shell configuration file.
|
||||||
dircolors program itself can be configured with a configuration file. dircolors
|
dircolors program itself can be configured with a configuration file.
|
||||||
supports 256 colors along with common attributes such as bold and underline.
|
dircolors supports 256 colors along with common attributes such as bold and underline.
|
||||||
|
|
||||||
If '$LS_COLORS' variable is not set, '$LSCOLORS' variable is checked instead.
|
If '$LS_COLORS' variable is not set, '$LSCOLORS' variable is checked instead.
|
||||||
This variable is used by ls programs on unix systems such as Mac and BSDs. This
|
This variable is used by ls programs on unix systems such as Mac and BSDs.
|
||||||
variable has a simple syntax and supports 8 colors and bold attribute.
|
This variable has a simple syntax and supports 8 colors and bold attribute.
|
||||||
|
|
||||||
If both of these environment variables are not set, then lf fallbacks to its
|
If both of these environment variables are not set, then lf fallbacks to its default colorscheme.
|
||||||
default colorscheme. Default lf colors are taken from GNU dircolors defaults.
|
Default lf colors are taken from GNU dircolors defaults.
|
||||||
These defaults use 8 basic colors and bold attribute.
|
These defaults use 8 basic colors and bold attribute.
|
||||||
|
|
||||||
It is worth noting that lf uses as many colors are advertised by your terminal's
|
It is worth noting that lf uses as many colors are advertised by your terminal's entry in your systems terminfo or infocmp database, if this is not present lf will default to an internal database.
|
||||||
entry in your systems terminfo or infocmp database, if this is not present lf
|
For terminals supporting 24-bit (or "true") color that do not have a database entry (or one that does not advertise all capabilities), support can be enabled by either setting the '$COLORTERM' variable to "truecolor" or ensuring '$TERM' is set to a value that ends with "-truecolor".
|
||||||
will default to an internal database. For terminals supporting 24-bit (or
|
|
||||||
"true") color that do not have a database entry (or one that does not advertise
|
|
||||||
all capabilities), support can be enabled by either setting the '$COLORTERM'
|
|
||||||
variable to "truecolor" or ensuring '$TERM' is set to a value that ends with
|
|
||||||
"-truecolor".
|
|
||||||
|
|
||||||
Keeping this in mind, you can configure lf colors in two different ways. First,
|
Keeping this in mind, you can configure lf colors in two different ways.
|
||||||
you can configure 8 basic colors used by your terminal and lf should pick up
|
First, you can configure 8 basic colors used by your terminal and lf should pick up those colors automatically.
|
||||||
those colors automatically. Depending on your terminal, you should be able to
|
Depending on your terminal, you should be able to select your colors from a 24-bit palette.
|
||||||
select your colors from a 24-bit palette. This is the recommended approach as
|
This is the recommended approach as colors used by other programs will also match each other.
|
||||||
colors used by other programs will also match each other.
|
|
||||||
|
|
||||||
Second, you can set the values of environmental variables mentioned above for
|
Second, you can set the values of environmental variables mentioned above for fine grained customization.
|
||||||
fine grained customization. This is useful to change colors used for different
|
This is useful to change colors used for different file types and extensions.
|
||||||
file types and extensions. '$LS_COLORS' is more powerful than '$LSCOLORS' and it
|
'$LS_COLORS' is more powerful than '$LSCOLORS' and it can be used even when GNU programs are not installed on the system.
|
||||||
can be used even when GNU programs are not installed on the system. You can
|
You can combine this second method with the first method for best results.
|
||||||
combine this second method with the first method for best results.
|
|
||||||
|
|
||||||
Lastly, you may also want to configure the colors of the prompt line to match
|
Lastly, you may also want to configure the colors of the prompt line to match the rest of the colors.
|
||||||
the rest of the colors. Colors of the prompt line can be configured using the
|
Colors of the prompt line can be configured using the 'promptfmt' option which can include hardcoded colors as ansi escapes.
|
||||||
'promptfmt' option which can include hardcoded colors as ansi escapes. See the
|
See the default value of this option to have an idea about how to color this line.
|
||||||
default value of this option to have an idea about how to color this line.
|
|
||||||
*/
|
*/
|
||||||
package main
|
package main
|
||||||
|
Loading…
Reference in New Issue
Block a user