@@ -53,23 +53,23 @@ The following commands are provided by lf without default keybindings:
53
53
The following command line commands are provided by lf with default
54
54
keybindings:
55
55
56
- cmd-escape (default '<esc>')
57
- cmd-comp (default '<tab>')
58
- cmd-enter (default '<c-j>' and '<enter>')
59
- cmd-hist-next (default '<c-n>')
60
- cmd-hist-prev (default '<c-p>')
61
- cmd-delete (default '<c-d>' and '<delete>')
62
- cmd-delete-back (default '<bs>' and '<bs2>')
63
- cmd-left (default '<c-b>' and '<left>')
64
- cmd-right (default '<c-f>' and '<right>')
65
- cmd-beg (default '<c-a>' and '<home>')
66
- cmd-end (default '<c-e>' and '<end>')
67
- cmd-delete-beg (default '<c-u>')
68
- cmd-delete-end (default '<c-k>')
69
- cmd-delete-word (default '<c-w>')
70
- cmd-put (default '<c-y>')
71
- cmd-transpose (default '<c-t>')
72
- cmd-interrupt (default '<c-c>')
56
+ cmd-escape (default '<esc>')
57
+ cmd-comp (default '<tab>')
58
+ cmd-enter (default '<c-j>' and '<enter>')
59
+ cmd-hist-next (default '<c-n>')
60
+ cmd-hist-prev (default '<c-p>')
61
+ cmd-delete (default '<c-d>' and '<delete>')
62
+ cmd-delete-back (default '<bs>' and '<bs2>')
63
+ cmd-left (default '<c-b>' and '<left>')
64
+ cmd-right (default '<c-f>' and '<right>')
65
+ cmd-beg (default '<c-a>' and '<home>')
66
+ cmd-end (default '<c-e>' and '<end>')
67
+ cmd-delete-beg (default '<c-u>')
68
+ cmd-delete-end (default '<c-k>')
69
+ cmd-delete-word (default '<c-w>')
70
+ cmd-put (default '<c-y>')
71
+ cmd-transpose (default '<c-t>')
72
+ cmd-interrupt (default '<c-c>')
73
73
74
74
The following options can be used to customize the behavior of lf:
75
75
@@ -146,9 +146,9 @@ The following command prefixes are used by lf:
146
146
147
147
: read (default) builtin/custom command
148
148
$ shell shell command
149
- % shell-pipe shell command displaying the output
149
+ % shell-pipe shell command running with the ui
150
150
! shell-wait shell command waiting for key press
151
- & shell-async asynchronous shell command
151
+ & shell-async shell command running asynchronously
152
152
/ search search file in current directory
153
153
? search-back search file in the reverse order
154
154
@@ -219,7 +219,7 @@ prefix.
219
219
set info time
220
220
}}
221
221
222
- Mappings
222
+ Push Mappings
223
223
224
224
The usual way to map a key sequence is to assign it to a named or unnamed
225
225
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:
244
244
245
245
These types of bindings create a deadlock when executed.
246
246
247
- Commands
247
+ Shell Commands ($)
248
248
249
- For demonstration let us write a shell command to move selected file(s) to
250
- trash.
251
-
252
- A first attempt to write such a command may look like this:
249
+ Regular shell commands are the most basic command type that is useful for many
250
+ purposes. For example, we can write a shell command to move selected file(s) to
251
+ trash. A first attempt to write such a command may look like this:
253
252
254
253
cmd trash ${{
255
254
mkdir -p ~/.trash
@@ -289,6 +288,47 @@ could use the 'ifs' option to set it for all shell commands (i.e. 'set ifs
289
288
behave unexpectedly for new users. However, use of this option is highly
290
289
recommended and it is assumed in the rest of the documentation.
291
290
291
+ Piping Shell Commands (%)
292
+
293
+ Regular shell commands have some limitations in some cases. When an output or
294
+ error message is given and the command exits afterwards, the ui is immediately
295
+ resumed and there is no way to see the message without dropping to shell again.
296
+ Also, even when there is no output or error, the ui still needs to be paused
297
+ while the command is running. This can cause flickering on the screen for short
298
+ commands and similar distractions for longer commands.
299
+
300
+ Instead of pausing the ui, piping shell commands connects stdin, stdout, and
301
+ stderr of the command to the statline in the bottom of the ui. This can be
302
+ useful for programs following the unix philosophy to give no output in the
303
+ success case, and brief error messages or prompts in other cases.
304
+
305
+ For example, following rename command prompts for overwrite in the statline if
306
+ there is an existing file with the given name:
307
+
308
+ cmd rename %mv -i $f $1
309
+
310
+ You can also output error messages in the command and it will show up in the
311
+ statline. For example, an alternative rename command may look like this:
312
+
313
+ cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
314
+
315
+ One thing to be careful is that although input is still line buffered, output
316
+ and error are byte buffered and verbose commands will be very slow to display.
317
+
318
+ Waiting Shell Commands (!)
319
+
320
+ Waiting shell commands are similar to regular shell commands except that they
321
+ wait for a key press when the command is finished. These can be useful to see
322
+ the output of a program before the ui is resumed. Waiting shell commands are
323
+ more appropriate than piping shell commands when the command is verbose and the
324
+ output is best displayed as multiline.
325
+
326
+ Asynchronous Shell Commands (&)
327
+
328
+ Asynchronous shell commands are used to start a command in the background and
329
+ then resume operation without waiting for the command to finish. Stdin, stdout,
330
+ and stderr of the command is neither connected to the terminal nor to the ui.
331
+
292
332
Remote Commands
293
333
294
334
One of the more advanced features in lf is remote commands. All clients connect
@@ -325,15 +365,17 @@ a shell command:
325
365
lf -remote "send $id echo hello world"
326
366
327
367
Since lf does not have control flow syntax, remote commands are used for such
328
- needs. A common use is to display an error message back in the client. You can
329
- implement a safe rename command which does not overwrite an existing file or
330
- directory as such:
331
-
332
- cmd rename ${{
333
- if [ -e $1 ]; then
334
- lf -remote "send $id echo file exists"
368
+ needs. For example, you can configure the number of columns in the ui with
369
+ respect to the terminal width as follows:
370
+
371
+ cmd recol ${{
372
+ w=$(tput cols)
373
+ if [ $w -le 80 ]; then
374
+ lf -remote "send $id set ratios 1:2"
375
+ elif [ $w -le 160 ]; then
376
+ lf -remote "send $id set ratios 1:2:3"
335
377
else
336
- mv $f $1
378
+ lf -remote "send $id set ratios 1:2:3:5"
337
379
fi
338
380
}}
339
381
0 commit comments