update documentation
This commit is contained in:
parent
54315ffde2
commit
01581f902f
106
doc.go
106
doc.go
@ -53,23 +53,23 @@ 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-beg (default '<c-u>')
|
cmd-delete-beg (default '<c-u>')
|
||||||
cmd-delete-end (default '<c-k>')
|
cmd-delete-end (default '<c-k>')
|
||||||
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>')
|
||||||
cmd-interrupt (default '<c-c>')
|
cmd-interrupt (default '<c-c>')
|
||||||
|
|
||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
|
|
||||||
@ -146,9 +146,9 @@ The following command prefixes are used by lf:
|
|||||||
|
|
||||||
: read (default) builtin/custom command
|
: read (default) builtin/custom command
|
||||||
$ shell shell command
|
$ shell shell command
|
||||||
% shell-pipe shell command displaying the output
|
% shell-pipe shell command running with the ui
|
||||||
! shell-wait shell command waiting for key press
|
! shell-wait shell command waiting for key press
|
||||||
& shell-async asynchronous shell command
|
& shell-async shell command running asynchronously
|
||||||
/ search search file in current directory
|
/ search search file in current directory
|
||||||
? search-back search file in the reverse order
|
? search-back search file in the reverse order
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ prefix.
|
|||||||
set info time
|
set info time
|
||||||
}}
|
}}
|
||||||
|
|
||||||
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. 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
|
||||||
@ -244,12 +244,11 @@ commands it is possible to accidentally create recursive bindings:
|
|||||||
|
|
||||||
These types of bindings create a deadlock when executed.
|
These types of bindings create a deadlock when executed.
|
||||||
|
|
||||||
Commands
|
Shell Commands ($)
|
||||||
|
|
||||||
For demonstration let us write a shell command to move selected file(s) to
|
Regular shell commands are the most basic command type that is useful for many
|
||||||
trash.
|
purposes. For example, we can write a shell command to move selected file(s) to
|
||||||
|
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
|
||||||
@ -289,6 +288,47 @@ could use the 'ifs' option to set it for all shell commands (i.e. 'set ifs
|
|||||||
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.
|
||||||
|
|
||||||
|
Piping Shell Commands (%)
|
||||||
|
|
||||||
|
Regular shell commands have some limitations in some cases. 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.
|
||||||
|
Also, even when there is no output or error, the ui still needs to be paused
|
||||||
|
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
|
||||||
|
stderr of the command to the statline in the bottom of the ui. 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.
|
||||||
|
|
||||||
|
For example, following rename command prompts for overwrite in the statline if
|
||||||
|
there is an existing file with the given name:
|
||||||
|
|
||||||
|
cmd rename %mv -i $f $1
|
||||||
|
|
||||||
|
You can also output error messages in the command and it will show up in the
|
||||||
|
statline. For example, an alternative rename command may look like this:
|
||||||
|
|
||||||
|
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Waiting Shell Commands (!)
|
||||||
|
|
||||||
|
Waiting shell commands are similar to regular shell commands except that they
|
||||||
|
wait for a key press when the command is finished. These can be useful to see
|
||||||
|
the output of a program before the ui is resumed. Waiting shell commands are
|
||||||
|
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 are used to start a command in the background and
|
||||||
|
then resume operation without waiting for the command to finish. Stdin, stdout,
|
||||||
|
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. All clients connect
|
||||||
@ -325,15 +365,17 @@ 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. A common use is to display an error message back in the client. You can
|
needs. For example, you can configure the number of columns in the ui with
|
||||||
implement a safe rename command which does not overwrite an existing file or
|
respect to the terminal width as follows:
|
||||||
directory as such:
|
|
||||||
|
|
||||||
cmd rename ${{
|
cmd recol ${{
|
||||||
if [ -e $1 ]; then
|
w=$(tput cols)
|
||||||
lf -remote "send $id echo file exists"
|
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
|
else
|
||||||
mv $f $1
|
lf -remote "send $id set ratios 1:2:3:5"
|
||||||
fi
|
fi
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
111
docstring.go
111
docstring.go
@ -57,23 +57,23 @@ 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-beg (default '<c-u>')
|
cmd-delete-beg (default '<c-u>')
|
||||||
cmd-delete-end (default '<c-k>')
|
cmd-delete-end (default '<c-k>')
|
||||||
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>')
|
||||||
cmd-interrupt (default '<c-c>')
|
cmd-interrupt (default '<c-c>')
|
||||||
|
|
||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
|
|
||||||
@ -153,9 +153,9 @@ The following command prefixes are used by lf:
|
|||||||
|
|
||||||
: read (default) builtin/custom command
|
: read (default) builtin/custom command
|
||||||
$ shell shell command
|
$ shell shell command
|
||||||
% shell-pipe shell command displaying the output
|
% shell-pipe shell command running with the ui
|
||||||
! shell-wait shell command waiting for key press
|
! shell-wait shell command waiting for key press
|
||||||
& shell-async asynchronous shell command
|
& shell-async shell command running asynchronously
|
||||||
/ search search file in current directory
|
/ search search file in current directory
|
||||||
? search-back search file in the reverse order
|
? search-back search file in the reverse order
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ proper prefix.
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
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. While this provides a clean way to remap builtin keys as well as
|
command. While this provides a clean way to remap builtin keys as well as
|
||||||
@ -254,13 +254,12 @@ of commands it is possible to accidentally create recursive bindings:
|
|||||||
|
|
||||||
These types of bindings create a deadlock when executed.
|
These types of bindings create a deadlock when executed.
|
||||||
|
|
||||||
|
Shell Commands ($)
|
||||||
|
|
||||||
Commands
|
Regular shell commands are the most basic command type that is useful for
|
||||||
|
many purposes. For example, we can write a shell command to move selected
|
||||||
For demonstration let us write a shell command to move selected file(s) to
|
file(s) to trash. A first attempt to write such a command may look like
|
||||||
trash.
|
this:
|
||||||
|
|
||||||
A first attempt to write such a command may look like this:
|
|
||||||
|
|
||||||
cmd trash ${{
|
cmd trash ${{
|
||||||
mkdir -p ~/.trash
|
mkdir -p ~/.trash
|
||||||
@ -301,6 +300,50 @@ or '$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.
|
||||||
|
|
||||||
|
Piping Shell Commands (%)
|
||||||
|
|
||||||
|
Regular shell commands have some limitations in some cases. 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. Also, even when there is no output or error, the ui still
|
||||||
|
needs to be paused 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
|
||||||
|
stderr of the command to the statline in the bottom of the ui. 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.
|
||||||
|
|
||||||
|
For example, following rename command prompts for overwrite in the statline
|
||||||
|
if there is an existing file with the given name:
|
||||||
|
|
||||||
|
cmd rename %mv -i $f $1
|
||||||
|
|
||||||
|
You can also output error messages in the command and it will show up in the
|
||||||
|
statline. For example, an alternative rename command may look like this:
|
||||||
|
|
||||||
|
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Waiting Shell Commands (!)
|
||||||
|
|
||||||
|
Waiting shell commands are similar to regular shell commands except that
|
||||||
|
they wait for a key press when the command is finished. These can be useful
|
||||||
|
to see the output of a program before the ui is resumed. Waiting shell
|
||||||
|
commands are 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 are used to start a command in the background
|
||||||
|
and then resume operation without waiting for the command to finish. Stdin,
|
||||||
|
stdout, and stderr of the command is neither connected to the terminal nor
|
||||||
|
to the ui.
|
||||||
|
|
||||||
|
|
||||||
Remote Commands
|
Remote Commands
|
||||||
|
|
||||||
@ -339,15 +382,17 @@ 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
|
Since lf does not have control flow syntax, remote commands are used for
|
||||||
such needs. A common use is to display an error message back in the client.
|
such needs. For example, you can configure the number of columns in the ui
|
||||||
You can implement a safe rename command which does not overwrite an existing
|
with respect to the terminal width as follows:
|
||||||
file or directory as such:
|
|
||||||
|
|
||||||
cmd rename ${{
|
cmd recol ${{
|
||||||
if [ -e $1 ]; then
|
w=$(tput cols)
|
||||||
lf -remote "send $id echo file exists"
|
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
|
else
|
||||||
mv $f $1
|
lf -remote "send $id set ratios 1:2:3:5"
|
||||||
fi
|
fi
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -37,24 +37,15 @@ cmd open-file ${{
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
# rename current file without overwrite
|
# rename current file without overwrite
|
||||||
cmd rename ${{
|
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
||||||
if [ -e $1 ]; then
|
|
||||||
lf -remote "send $id echo file exists"
|
|
||||||
else
|
|
||||||
mv $f $1
|
|
||||||
fi
|
|
||||||
}}
|
|
||||||
map r push :rename<space>
|
map r push :rename<space>
|
||||||
|
|
||||||
# show disk usage
|
|
||||||
cmd usage $du -h . | less
|
|
||||||
|
|
||||||
# make sure trash folder exists
|
# make sure trash folder exists
|
||||||
$mkdir -p ~/.trash
|
%mkdir -p ~/.trash
|
||||||
|
|
||||||
# move current file or selected files to trash folder
|
# move current file or selected files to trash folder
|
||||||
# (also see 'man mv' for backup/overwrite options)
|
# (also see 'man mv' for backup/overwrite options)
|
||||||
cmd trash $mv $fx ~/.trash
|
cmd trash %mv $fx ~/.trash
|
||||||
|
|
||||||
# remove current file or selected files (prompting)
|
# remove current file or selected files (prompting)
|
||||||
cmd remove ${{
|
cmd remove ${{
|
||||||
@ -66,7 +57,7 @@ cmd remove ${{
|
|||||||
|
|
||||||
# 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/)
|
||||||
cmd extract ${{
|
cmd extract %{{
|
||||||
case $f in
|
case $f in
|
||||||
*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
|
*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
|
||||||
*.tar.gz|*.tgz) tar xzvf $f;;
|
*.tar.gz|*.tgz) tar xzvf $f;;
|
||||||
@ -77,12 +68,10 @@ cmd extract ${{
|
|||||||
esac
|
esac
|
||||||
}}
|
}}
|
||||||
|
|
||||||
# compress marked files with tar and gunzip
|
# compress current file or selected files with tar and gunzip
|
||||||
# This command takes the output name without '.tar.gz' suffix as an argument
|
cmd compress %{{
|
||||||
# (e.g. 'compress foo' creates 'foo.tar.gz').
|
|
||||||
cmd compress ${{
|
|
||||||
mkdir $1
|
mkdir $1
|
||||||
cp $fs $1
|
cp -r $fx $1
|
||||||
tar czvf $1.tar.gz $1
|
tar czf $1.tar.gz $1
|
||||||
rm -rf $1
|
rm -rf $1
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user