Debian Codegraph @

lf.1

raw
1 .\" Automatically generated by Pandoc 3.7.0.2
2 .\"
3 .TH "LF" "1" "2026\-07\-31" "r42" "DOCUMENTATION"
4 .SH NAME
5 lf \- terminal file manager
6 .SH SYNOPSIS
7 \f[B]lf\f[R] [\f[B]\-command\f[R] \f[I]command\f[R]] [\f[B]\-config\f[R]
8 \f[I]path\f[R]] [\f[B]\-cpuprofile\f[R] \f[I]path\f[R]]
9 [\f[B]\-doc\f[R]] [\f[B]\-help\f[R]] [\f[B]\-last\-dir\-path\f[R]
10 \f[I]path\f[R]] [\f[B]\-log\f[R] \f[I]path\f[R]] [\f[B]\-memprofile\f[R]
11 \f[I]path\f[R]] [\f[B]\-print\-last\-dir\f[R]]
12 [\f[B]\-print\-selection\f[R]] [\f[B]\-remote\f[R] \f[I]command\f[R]]
13 [\f[B]\-selection\-path\f[R] \f[I]path\f[R]] [\f[B]\-server\f[R]]
14 [\f[B]\-single\f[R]] [\f[B]\-version\f[R]]
15 [\f[I]cd\-or\-select\-path\f[R]]
16 .SH DESCRIPTION
17 lf is a terminal file manager.
18 .PP
19 The source code can be found in the repository at \c
20 .UR https://github.com/gokcehan/lf
21 .UE \c
22 .PP
23 This documentation can either be read from the terminal using
24 \f[CR]lf \-doc\f[R] or online at \c
25 .UR https://github.com/gokcehan/lf/blob/master/doc.md
26 .UE \c
27 \ You can also use the \f[CR]help\f[R] command (default
28 \f[CR]<f\-1>\f[R]) inside lf to view the documentation in a pager.
29 A man page with the same content is also available in the repository at
30 \c
31 .UR https://github.com/gokcehan/lf/blob/master/lf.1
32 .UE \c
33 .SH OPTIONS
34 .SS POSITIONAL ARGUMENTS
35 .TP
36 \f[B]cd\-or\-select\-path\f[R]
37 Set the starting location.
38 If \f[I]path\f[R] is a directory, start in there.
39 If it\(aqs a file, start in the file\(aqs parent directory and select
40 the file.
41 When no \f[I]path\f[R] is supplied, lf uses the current directory.
42 Only accepts one argument.
43 .SS META OPTIONS
44 .TP
45 \f[B]\-doc\f[R]
46 Show lf\(aqs documentation (same content as this file) and exit.
47 .TP
48 \f[B]\-help\f[R]
49 Show command\-line usage and exit.
50 .TP
51 \f[B]\-version\f[R]
52 Show version information and exit.
53 .SS STARTUP & CONFIGURATION
54 .TP
55 \f[B]\-command\f[R] \f[I]command\f[R]
56 Execute \f[I]command\f[R] during client initialization (i.e.
57 after reading configuration, before \f[CR]on\-init\f[R]).
58 To execute more than one command, you can either use the
59 \f[B]\-command\f[R] flag multiple times or pass multiple commands at
60 once by chaining them with \(dq;\(dq.
61 .TP
62 \f[B]\-config\f[R] \f[I]path\f[R]
63 Use the config file at \f[I]path\f[R] instead of the normal search
64 locations.
65 This only affects which \f[CR]lfrc\f[R] is read at startup.
66 .SS SHELL INTEGRATION
67 .TP
68 \f[B]\-print\-last\-dir\f[R]
69 Print the last directory to stdout when lf exits.
70 This can be used to let lf change your shell\(aqs working directory.
71 See \f[CR]CHANGING DIRECTORY\f[R] for more details.
72 .TP
73 \f[B]\-last\-dir\-path\f[R] \f[I]path\f[R]
74 Same as \f[B]\-print\-last\-dir\f[R], but write the directory to
75 \f[I]path\f[R] instead of stdout.
76 .TP
77 \f[B]\-print\-selection\f[R]
78 Print selected files to stdout when opening a file in lf.
79 This can be used to use lf as an \(dqopen file\(dq dialog.
80 First, select the files you want to pass to another program.
81 Then, confirm the selection by opening a file.
82 This causes lf to quit and print out the selection.
83 Quitting lf prematurely discards the selection.
84 .TP
85 \f[B]\-selection\-path\f[R] \f[I]path\f[R]
86 Same as \f[B]\-print\-selection\f[R], but write the newline\-separated
87 list to \f[I]path\f[R] instead of stdout.
88 .SS SERVER
89 .TP
90 \f[B]\-remote\f[R] \f[I]command\f[R]
91 Send \f[I]command\f[R] to the running server (i.e.
92 \f[CR]send\f[R], \f[CR]query\f[R], \f[CR]list\f[R], \f[CR]quit\f[R], or
93 \f[CR]quit!\f[R]).
94 See \f[CR]REMOTE COMMANDS\f[R] for more details.
95 .TP
96 \f[B]\-server\f[R]
97 Start the (headless) server process explicitly.
98 Runs in the foreground and writes server logs to stderr (or the file set
99 with \f[B]\-log\f[R]).
100 Clients auto\-start a server if none is running unless
101 \f[B]\-single\f[R] is used.
102 .TP
103 \f[B]\-single\f[R]
104 Start a stand\-alone client without a server.
105 Disables remote control.
106 .SS DIAGNOSTICS
107 .TP
108 \f[B]\-log\f[R] \f[I]path\f[R]
109 Append runtime log messages to \f[I]path\f[R].
110 .TP
111 \f[B]\-cpuprofile\f[R] \f[I]path\f[R]
112 Write a CPU profile to \f[I]path\f[R].
113 The profile can be used by \f[CR]go tool pprof\f[R].
114 .TP
115 \f[B]\-memprofile\f[R] \f[I]path\f[R]
116 Write a memory profile to \f[I]path\f[R].
117 The profile can be used by \f[CR]go tool pprof\f[R].
118 .SS EXAMPLES
119 Use \f[CR]lf\f[R] to select files (while hiding certain file types):
120 .IP
121 .EX
122 lf \-command \(aqset nohidden\(aq \-command \(aqset hiddenfiles \(dq*mp4:*pdf:*txt\(dq\(aq \-print\-selection
123 .EE
124 .PP
125 Another sophisticated \(dqopen file\(dq dialog focusing on design:
126 .IP
127 .EX
128 lf \-command \(aqset nopreview; set ratios 1; set drawbox; set promptfmt \(dqSelect files [%w] %S q: cancel, l: confirm\(dq\(aq \-print\-selection
129 .EE
130 .PP
131 Open Downloads and set \f[CR]sortby\f[R] and \f[CR]info\f[R] to creation
132 date:
133 .IP
134 .EX
135 lf \-command \(aqset sortby btime; set info btime\(aq \(ti/Downloads
136 .EE
137 .PP
138 Temporarily prevent \f[CR]lf\f[R] from modifying the command history:
139 .IP
140 .EX
141 lf \-command \(aqset nohistory\(aq
142 .EE
143 .PP
144 Use default settings and log current session:
145 .IP
146 .EX
147 lf \-config /dev/null \-log /tmp/lf.log
148 .EE
149 .PP
150 Force\-quit the server:
151 .IP
152 .EX
153 lf \-remote \(aqquit!\(aq
154 .EE
155 .PP
156 Inherit lf\(aqs working directory in your shell:
157 .IP
158 .EX
159 cd \(dq$(lf \-print\-last\-dir)\(dq
160 .EE
161 .SH QUICK REFERENCE
162 The following commands are provided by lf:
163 .IP
164 .EX
165 quit (default \(aqq\(aq)
166 up (default \(aqk\(aq and \(aq<up>\(aq)
167 half\-up (default \(aq<c\-u>\(aq)
168 page\-up (default \(aq<c\-b>\(aq and \(aq<pgup>\(aq)
169 scroll\-up (default \(aq<c\-y>\(aq)
170 down (default \(aqj\(aq and \(aq<down>\(aq)
171 half\-down (default \(aq<c\-d>\(aq)
172 page\-down (default \(aq<c\-f>\(aq and \(aq<pgdn>\(aq)
173 scroll\-down (default \(aq<c\-e>\(aq)
174 updir (default \(aqh\(aq and \(aq<left>\(aq)
175 open (default \(aql\(aq and \(aq<right>\(aq)
176 jump\-next (default \(aq]\(aq)
177 jump\-prev (default \(aq[\(aq)
178 top (default \(aqgg\(aq and \(aq<home>\(aq)
179 bottom (default \(aqG\(aq and \(aq<end>\(aq)
180 high (default \(aqH\(aq)
181 middle (default \(aqM\(aq)
182 low (default \(aqL\(aq)
183 toggle
184 invert (default \(aqv\(aq)
185 unselect (default \(aqu\(aq)
186 glob\-select
187 glob\-unselect
188 copy (default \(aqy\(aq)
189 cut (default \(aqd\(aq)
190 paste (default \(aqp\(aq)
191 clear (default \(aqc\(aq)
192 sync
193 draw
194 redraw (default \(aq<c\-l>\(aq)
195 load
196 reload (default \(aq<c\-r>\(aq)
197 delete (modal)
198 rename (modal) (default \(aqr\(aq)
199 read (modal) (default \(aq:\(aq)
200 shell (modal) (default \(aq$\(aq)
201 shell\-pipe (modal) (default \(aq%\(aq)
202 shell\-wait (modal) (default \(aq!\(aq)
203 shell\-async (modal) (default \(aq&\(aq)
204 find (modal) (default \(aqf\(aq)
205 find\-back (modal) (default \(aqF\(aq)
206 find\-next (default \(aq;\(aq)
207 find\-prev (default \(aq,\(aq)
208 search (modal) (default \(aq/\(aq)
209 search\-back (modal) (default \(aq?\(aq)
210 search\-next (default \(aqn\(aq)
211 search\-prev (default \(aqN\(aq)
212 filter (modal)
213 setfilter
214 mark\-save (modal) (default \(aqm\(aq)
215 mark\-load (modal) (default \(dq\(aq\(dq)
216 mark\-remove (modal) (default \(aq\(dq\(aq)
217 tag
218 tag\-toggle (default \(aqt\(aq)
219 echo
220 echomsg
221 echoerr
222 cd
223 select
224 source
225 push
226 addcustominfo
227 calcdirsize
228 clearmaps
229 tty\-write
230 visual (default \(aqV\(aq)
231 .EE
232 .PP
233 The following Visual mode commands are provided by lf:
234 .IP
235 .EX
236 visual\-accept (default \(aqV\(aq)
237 visual\-unselect
238 visual\-discard (default \(aq<esc>\(aq)
239 visual\-change (default \(aqo\(aq)
240 .EE
241 .PP
242 The following Command\-line mode commands are provided by lf:
243 .IP
244 .EX
245 cmd\-insert
246 cmd\-escape (default \(aq<esc>\(aq)
247 cmd\-complete (default \(aq<tab>\(aq)
248 cmd\-menu\-complete
249 cmd\-menu\-complete\-back
250 cmd\-menu\-accept
251 cmd\-menu\-discard
252 cmd\-enter (default \(aq<c\-j>\(aq and \(aq<enter>\(aq)
253 cmd\-interrupt (default \(aq<c\-c>\(aq)
254 cmd\-history\-next (default \(aq<c\-n>\(aq and \(aq<down>\(aq)
255 cmd\-history\-prev (default \(aq<c\-p>\(aq and \(aq<up>\(aq)
256 cmd\-left (default \(aq<c\-b>\(aq and \(aq<left>\(aq)
257 cmd\-right (default \(aq<c\-f>\(aq and \(aq<right>\(aq)
258 cmd\-home (default \(aq<c\-a>\(aq and \(aq<home>\(aq)
259 cmd\-end (default \(aq<c\-e>\(aq and \(aq<end>\(aq)
260 cmd\-delete (default \(aq<c\-d>\(aq and \(aq<delete>\(aq)
261 cmd\-delete\-back (default \(aq<backspace>\(aq)
262 cmd\-delete\-home (default \(aq<c\-u>\(aq)
263 cmd\-delete\-end (default \(aq<c\-k>\(aq)
264 cmd\-delete\-unix\-word (default \(aq<c\-w>\(aq)
265 cmd\-yank (default \(aq<c\-y>\(aq)
266 cmd\-transpose (default \(aq<c\-t>\(aq)
267 cmd\-transpose\-word (default \(aq<a\-t>\(aq)
268 cmd\-word (default \(aq<a\-f>\(aq)
269 cmd\-word\-back (default \(aq<a\-b>\(aq)
270 cmd\-delete\-word (default \(aq<a\-d>\(aq)
271 cmd\-delete\-word\-back (default \(aq<a\-backspace>\(aq)
272 cmd\-capitalize\-word (default \(aq<a\-c>\(aq)
273 cmd\-uppercase\-word (default \(aq<a\-u>\(aq)
274 cmd\-lowercase\-word (default \(aq<a\-l>\(aq)
275 .EE
276 .PP
277 The following options can be used to customize the behavior of lf:
278 .IP
279 .EX
280 anchorfind bool (default true)
281 autoquit bool (default true)
282 borderfmt string (default \(dq\(rs033[0m\(dq)
283 borderstyle string (default \(aqbox\(aq)
284 cleaner string (default \(aq\(aq)
285 copyfmt string (default \(dq\(rs033[7;33m\(dq)
286 cursoractivefmt string (default \(dq\(rs033[7m\(dq)
287 cursorparentfmt string (default \(dq\(rs033[7m\(dq)
288 cursorpreviewfmt string (default \(dq\(rs033[4m\(dq)
289 cutfmt string (default \(dq\(rs033[7;31m\(dq)
290 dircounts bool (default false)
291 dirfirst bool (default true)
292 dironly bool (default false)
293 dirpreviews bool (default false)
294 drawbox bool (default false)
295 dupfilefmt string (default \(aq%f.\(ti%n\(ti\(aq)
296 errorfmt string (default \(dq\(rs033[7;31;47m\(dq)
297 filesep string (default \(dq\(rsn\(dq)
298 filtermethod string (default \(aqtext\(aq)
299 findlen int (default 1)
300 hidden bool (default false)
301 hiddenfiles []string (default \(aq.*\(aq for Unix and \(aq\(aq for Windows)
302 history bool (default true)
303 icons bool (default false)
304 ifs string (default \(aq\(aq)
305 ignorecase bool (default true)
306 ignoredia bool (default true)
307 incfilter bool (default false)
308 incsearch bool (default false)
309 info []string (default \(aq\(aq)
310 infotimefmtnew string (default \(aqJan _2 15:04\(aq)
311 infotimefmtold string (default \(aqJan _2 2006\(aq)
312 menufmt string (default \(dq\(rs033[0m\(dq)
313 menuheaderfmt string (default \(dq\(rs033[1m\(dq)
314 menuselectfmt string (default \(dq\(rs033[7m\(dq)
315 mergeindicators bool (default false)
316 mouse bool (default false)
317 number bool (default false)
318 numbercursorfmt string (default \(aq\(aq)
319 numberfmt string (default \(dq\(rs033[33m\(dq)
320 period int (default 0)
321 preload bool (default false)
322 preserve []string (default \(dqmode\(dq)
323 preview bool (default true)
324 previewer string (default \(aq\(aq)
325 promptfmt string (default \(dq\(rs033[32;1m%u\(at%h\(rs033[0m:\(rs033[34;1m%d\(rs033[0m\(rs033[1m%f\(rs033[0m\(dq)
326 ratios []int (default \(aq1:2:3\(aq)
327 relativenumber bool (default false)
328 reverse bool (default false)
329 rulerfile string (default \(dq\(dq)
330 rulerfmt string (default \(dq\(dq)
331 scrolloff int (default 0)
332 searchmethod string (default \(aqtext\(aq)
333 selectfmt string (default \(dq\(rs033[7;35m\(dq)
334 selmode string (default \(aqall\(aq)
335 shell string (default \(aqsh\(aq for Unix and \(aqcmd\(aq for Windows)
336 shellflag string (default \(aq\-c\(aq for Unix and \(aq/c\(aq for Windows)
337 shellopts []string (default \(aq\(aq)
338 showbinds bool (default true)
339 sizeunits string (default \(aqbinary\(aq)
340 smartcase bool (default true)
341 smartdia bool (default false)
342 sortby string (default \(aqnatural\(aq)
343 sortignorecase bool (default true)
344 sortignoredia bool (default true)
345 statfmt string (default \(dq\(rs033[36m%p\(rs033[0m| %c| %u| %g| %S| %t| \-> %l\(dq)
346 tabstop int (default 8)
347 tagfmt string (default \(dq\(rs033[31m\(dq)
348 tempmarks string (default \(aq\(aq)
349 terminalcursor string (default \(aqdefault\(aq)
350 timefmt string (default \(aqMon Jan _2 15:04:05 2006\(aq)
351 truncatechar string (default \(aq\(ti\(aq)
352 truncatepct int (default 100)
353 visualfmt string (default \(dq\(rs033[7;36m\(dq)
354 waitmsg string (default \(aqPress any key to continue\(aq)
355 watch bool (default false)
356 wrapscan bool (default true)
357 wrapscroll bool (default false)
358 user_{option} string (default none)
359 .EE
360 .PP
361 The following environment variables are exported for shell commands:
362 .IP
363 .EX
364 f
365 fs
366 fv
367 fx
368 id
369 PWD
370 OLDPWD
371 LF_LEVEL
372 OPENER
373 VISUAL
374 EDITOR
375 PAGER
376 SHELL
377 lf
378 lf_{option}
379 lf_user_{option}
380 lf_flag_{flag}
381 lf_width
382 lf_height
383 lf_count
384 lf_mode
385 .EE
386 .PP
387 The following special shell commands are used to customize the behavior
388 of lf when defined:
389 .IP
390 .EX
391 open
392 paste
393 rename
394 delete
395 pre\-cd
396 on\-cd
397 on\-load
398 on\-focus\-gained
399 on\-focus\-lost
400 on\-init
401 on\-select
402 on\-redraw
403 on\-quit
404 .EE
405 .PP
406 The following commands/keybindings are provided by default:
407 .IP
408 .EX
409 Unix
410 cmd open &$OPENER \(dq$f\(dq
411 map e $$EDITOR \(dq$f\(dq
412 map i $$PAGER \(dq$f\(dq
413 map w $$SHELL
414 cmd help $$lf \-doc | $PAGER
415 map <f\-1> help
416 cmd maps $lf \-remote \(dqquery $id maps\(dq | $PAGER
417 cmd nmaps $lf \-remote \(dqquery $id nmaps\(dq | $PAGER
418 cmd vmaps $lf \-remote \(dqquery $id vmaps\(dq | $PAGER
419 cmd cmaps $lf \-remote \(dqquery $id cmaps\(dq | $PAGER
420 cmd cmds $lf \-remote \(dqquery $id cmds\(dq | $PAGER
421
422 Windows
423 cmd open &%OPENER% %f%
424 map e $%EDITOR% %f%
425 map i !%PAGER% %f%
426 map w $%SHELL%
427 cmd help !%lf% \-doc | %PAGER%
428 map <f\-1> help
429 cmd maps !%lf% \-remote \(dqquery %id% maps\(dq | %PAGER%
430 cmd nmaps !%lf% \-remote \(dqquery %id% nmaps\(dq | %PAGER%
431 cmd vmaps !%lf% \-remote \(dqquery %id% vmaps\(dq | %PAGER%
432 cmd cmaps !%lf% \-remote \(dqquery %id% cmaps\(dq | %PAGER%
433 cmd cmds !%lf% \-remote \(dqquery %id% cmds\(dq | %PAGER%
434 .EE
435 .PP
436 The defaults for Windows are using \f[CR]cmd\f[R] syntax.
437 A \f[CR]PowerShell\f[R] compatible configuration file can be found at \c
438 .UR https://github.com/gokcehan/lf/blob/master/etc/lfrc.ps1.example
439 .UE \c
440 .PP
441 The following additional keybindings are provided by default:
442 .IP
443 .EX
444 map zh set hidden!
445 map zr set reverse!
446 map zn set info
447 map zs set info size
448 map zt set info time
449 map za set info size:time
450 map sn :set sortby natural; set info
451 map ss :set sortby size; set info size
452 map st :set sortby time; set info time
453 map sa :set sortby atime; set info atime
454 map sb :set sortby btime; set info btime
455 map sc :set sortby ctime; set info ctime
456 map se :set sortby ext; set info
457 map gh cd \(ti
458 nmap <space> :toggle; down
459 .EE
460 .PP
461 If the \f[CR]mouse\f[R] option is enabled, mouse buttons have the
462 following default effects:
463 .IP
464 .EX
465 Left mouse button
466 Click on a file or directory to select it.
467
468 Right mouse button
469 Enter a directory or open a file. Also works on the preview pane.
470
471 Scroll wheel
472 Move up or down. If Ctrl is pressed, scroll up or down.
473 .EE
474 .SH CONFIGURATION
475 Configuration files should be located at:
476 .IP
477 .EX
478 OS system\-wide user\-specific
479 Unix /etc/lf/lfrc \(ti/.config/lf/lfrc
480 Windows C:\(rsProgramData\(rslf\(rslfrc C:\(rsUsers\(rs<user>\(rsAppData\(rsRoaming\(rslf\(rslfrc
481 .EE
482 .PP
483 The colors file should be located at:
484 .IP
485 .EX
486 OS system\-wide user\-specific
487 Unix /etc/lf/colors \(ti/.config/lf/colors
488 Windows C:\(rsProgramData\(rslf\(rscolors C:\(rsUsers\(rs<user>\(rsAppData\(rsRoaming\(rslf\(rscolors
489 .EE
490 .PP
491 The icons file should be located at:
492 .IP
493 .EX
494 OS system\-wide user\-specific
495 Unix /etc/lf/icons \(ti/.config/lf/icons
496 Windows C:\(rsProgramData\(rslf\(rsicons C:\(rsUsers\(rs<user>\(rsAppData\(rsRoaming\(rslf\(rsicons
497 .EE
498 .PP
499 The selection file should be located at:
500 .IP
501 .EX
502 Unix \(ti/.local/share/lf/files
503 Windows C:\(rsUsers\(rs<user>\(rsAppData\(rsLocal\(rslf\(rsfiles
504 .EE
505 .PP
506 The marks file should be located at:
507 .IP
508 .EX
509 Unix \(ti/.local/share/lf/marks
510 Windows C:\(rsUsers\(rs<user>\(rsAppData\(rsLocal\(rslf\(rsmarks
511 .EE
512 .PP
513 The tags file should be located at:
514 .IP
515 .EX
516 Unix \(ti/.local/share/lf/tags
517 Windows C:\(rsUsers\(rs<user>\(rsAppData\(rsLocal\(rslf\(rstags
518 .EE
519 .PP
520 The history file should be located at:
521 .IP
522 .EX
523 Unix \(ti/.local/share/lf/history
524 Windows C:\(rsUsers\(rs<user>\(rsAppData\(rsLocal\(rslf\(rshistory
525 .EE
526 .PP
527 You can configure these locations with the following variables given
528 with their order of precedences and their default values:
529 .IP
530 .EX
531 Unix
532 $LF_CONFIG_HOME
533 $XDG_CONFIG_HOME
534 \(ti/.config
535
536 $LF_DATA_HOME
537 $XDG_DATA_HOME
538 \(ti/.local/share
539
540 Windows
541 %LF_CONFIG_HOME%
542 %XDG_CONFIG_HOME%
543 %APPDATA%
544
545 %LF_DATA_HOME%
546 %XDG_DATA_HOME%
547 %LOCALAPPDATA%
548 .EE
549 .PP
550 A sample configuration file can be found at \c
551 .UR https://github.com/gokcehan/lf/blob/master/etc/lfrc.example
552 .UE \c
553 .SH COMMANDS
554 This section shows information about built\-in commands.
555 Modal commands do not take any arguments, but instead change the
556 operation mode to read their input conveniently, and so they are meant
557 to be assigned to keybindings.
558 .SS quit (default \f[CR]q\f[R])
559 Quit lf and return to the shell.
560 .SS up (default \f[CR]k\f[R] and \f[CR]<up>\f[R]), half\-up (default \f[CR]<c\-u>\f[R]), page\-up (default \f[CR]<c\-b>\f[R] and \f[CR]<pgup>\f[R]), scroll\-up (default \f[CR]<c\-y>\f[R]), down (default \f[CR]j\f[R] and \f[CR]<down>\f[R]), half\-down (default \f[CR]<c\-d>\f[R]), page\-down (default \f[CR]<c\-f>\f[R] and \f[CR]<pgdn>\f[R]), scroll\-down (default \f[CR]<c\-e>\f[R])
561 Move/scroll the current file selection upwards/downwards by one/half a
562 page/full page.
563 .SS updir (default \f[CR]h\f[R] and \f[CR]<left>\f[R])
564 Change the current working directory to the parent directory.
565 .SS open (default \f[CR]l\f[R] and \f[CR]<right>\f[R])
566 If the current file is a directory, then change the current directory to
567 it, otherwise, execute the \f[CR]open\f[R] command.
568 A default \f[CR]open\f[R] command is provided to call the default system
569 opener asynchronously with the current file as the argument.
570 A custom \f[CR]open\f[R] command can be defined to override this
571 default.
572 .SS jump\-next (default \f[CR]]\f[R]), jump\-prev (default \f[CR][\f[R])
573 Change the current working directory to the next/previous jumplist item.
574 .SS top (default \f[CR]gg\f[R] and \f[CR]<home>\f[R]), bottom (default \f[CR]G\f[R] and \f[CR]<end>\f[R])
575 Move the current file selection to the top/bottom of the directory.
576 A count can be specified to move to a specific line, for example, use
577 \f[CR]3G\f[R] to move to the third line.
578 .SS high (default \f[CR]H\f[R]), middle (default \f[CR]M\f[R]), low (default \f[CR]L\f[R])
579 Move the current file selection to the high/middle/low of the screen.
580 .SS toggle
581 Toggle the selection of the current file or files given as arguments.
582 .SS invert (default \f[CR]v\f[R])
583 Reverse the selection of all files in the current directory (i.e.
584 \f[CR]toggle\f[R] all files).
585 Selections in other directories are not affected by this command.
586 You can define a new command to select all files in the directory by
587 combining \f[CR]invert\f[R] with \f[CR]unselect\f[R] (i.e.
588 \f[CR]cmd select\-all :unselect; invert\f[R]), though this will also
589 remove selections in other directories.
590 .SS unselect (default \f[CR]u\f[R])
591 Remove the selection of all files in all directories.
592 .SS glob\-select, glob\-unselect
593 Select/unselect files that match the given glob.
594 .SS copy (default \f[CR]y\f[R])
595 Save the paths of selected files to the clipboard as files to be copied.
596 If there are no selected files, the path of the current file is used
597 instead.
598 .SS cut (default \f[CR]d\f[R])
599 Save the paths of selected files to the clipboard as files to be moved.
600 If there are no selected files, the path of the current file is used
601 instead.
602 .SS paste (default \f[CR]p\f[R])
603 Copy/Move files in the clipboard to the current working directory.
604 A custom \f[CR]paste\f[R] command can be defined to override this
605 default.
606 .SS clear (default \f[CR]c\f[R])
607 Clear file paths in the clipboard.
608 .SS sync
609 Synchronize copied/cut files with the server.
610 This command is automatically called when required.
611 .SS draw
612 Draw the screen.
613 This command is automatically called when required.
614 .SS redraw (default \f[CR]<c\-l>\f[R])
615 Synchronize the terminal and redraw the screen.
616 .SS load
617 Load modified files and directories.
618 This command is automatically called when required.
619 .SS reload (default \f[CR]<c\-r>\f[R])
620 Flush the cache and reload all files and directories.
621 .SS delete (modal)
622 Remove the current file or selected file(s).
623 A custom \f[CR]delete\f[R] command can be defined to override this
624 default.
625 .SS rename (modal) (default \f[CR]r\f[R])
626 Rename the current file using the built\-in method.
627 A custom \f[CR]rename\f[R] command can be defined to override this
628 default.
629 .SS read (modal) (default \f[CR]:\f[R])
630 Read a command to evaluate.
631 .SS shell (modal) (default \f[CR]$\f[R])
632 Read a shell command to execute.
633 .SS shell\-pipe (modal) (default \f[CR]%\f[R])
634 Read a shell command to execute piping its standard I/O to the bottom
635 statline.
636 .SS shell\-wait (modal) (default \f[CR]!\f[R])
637 Read a shell command to execute and wait for a key press at the end.
638 .SS shell\-async (modal) (default \f[CR]&\f[R])
639 Read a shell command to execute asynchronously without standard I/O.
640 .SS find (modal) (default \f[CR]f\f[R]), find\-back (modal) (default \f[CR]F\f[R]), find\-next (default \f[CR];\f[R]), find\-prev (default \f[CR],\f[R])
641 Read key(s) to find the appropriate filename match in the
642 forward/backward direction and jump to the next/previous match.
643 .SS search (default \f[CR]/\f[R]), search\-back (default \f[CR]?\f[R]), search\-next (default \f[CR]n\f[R]), search\-prev (default \f[CR]N\f[R])
644 Read a pattern to search for a filename match in the forward/backward
645 direction and jump to the next/previous match.
646 .SS filter (modal), setfilter
647 Command \f[CR]filter\f[R] reads a pattern to filter out and only view
648 files matching the pattern.
649 Command \f[CR]setfilter\f[R] does the same but uses an argument to set
650 the filter immediately.
651 You can supply an argument to \f[CR]filter\f[R] to use as the starting
652 prompt.
653 .SS mark\-save (modal) (default \f[CR]m\f[R])
654 Save the current directory as a bookmark assigned to the given key.
655 .SS mark\-load (modal) (default \f[CR]\(aq\f[R])
656 Change the current directory to the bookmark assigned to the given key.
657 A special bookmark \f[CR]\(aq\f[R] holds the previous directory after a
658 \f[CR]mark\-load\f[R], \f[CR]cd\f[R], or \f[CR]select\f[R] command.
659 .SS mark\-remove (modal) (default \f[CR]\(dq\f[R])
660 Remove a bookmark assigned to the given key.
661 .SS tag
662 Tag a file with \f[CR]*\f[R] or a single\-width character given in the
663 argument.
664 You can define a new tag\-clearing command by combining \f[CR]tag\f[R]
665 with \f[CR]tag\-toggle\f[R] (i.e.
666 \f[CR]cmd tag\-clear :tag; tag\-toggle\f[R]).
667 .SS tag\-toggle (default \f[CR]t\f[R])
668 Tag a file with \f[CR]*\f[R] or a single\-width character given in the
669 argument if the file is untagged, otherwise remove the tag.
670 .SS echo
671 Print the given arguments to the message line at the bottom.
672 .SS echomsg
673 Print the given arguments to the message line at the bottom and also to
674 the log file.
675 .SS echoerr
676 Print given arguments to the message line at the bottom as
677 \f[CR]errorfmt\f[R] and also to the log file.
678 .SS cd
679 Change the working directory to the given argument.
680 .SS select
681 Change the current file selection to the given argument.
682 .SS source
683 Read the configuration file given in the argument.
684 .SS push
685 Simulate key pushes given in the argument.
686 .SS addcustominfo
687 Update the \f[CR]custom\f[R] info and \f[CR].Stat.CustomInfo\f[R] field
688 of the given file with the given string.
689 The info string may contain ANSI escape codes to further customize its
690 appearance.
691 If no info is provided, clear the file\(aqs info instead.
692 .SS calcdirsize
693 Calculate the total size for each of the selected directories.
694 Option \f[CR]info\f[R] should include \f[CR]size\f[R] and option
695 \f[CR]dircounts\f[R] should be disabled to show this size.
696 If the total size of a directory is not calculated, it will be shown as
697 \f[CR]\-\f[R].
698 .SS clearmaps
699 Remove all keybindings associated with the \f[CR]map\f[R],
700 \f[CR]nmap\f[R] and \f[CR]vmap\f[R] command.
701 This command can be used in the config file to remove the default
702 keybindings.
703 For safety purposes, \f[CR]:\f[R] is left mapped to the \f[CR]read\f[R]
704 command, and \f[CR]cmap\f[R] keybindings are retained so that it is
705 still possible to exit \f[CR]lf\f[R] using \f[CR]:quit\f[R].
706 .SS tty\-write
707 Write the given string to the tty.
708 This is useful for sending escape sequences to the terminal to control
709 its behavior (e.g.
710 OSC 0 to set the window title).
711 Using \f[CR]tty\-write\f[R] is preferred over directly writing to
712 \f[CR]/dev/tty\f[R] because the latter is not synchronized and can
713 interfere with drawing the UI.
714 .SS visual (default \f[CR]V\f[R])
715 Switch to Visual mode.
716 If already in Visual mode, discard the visual selection and stay in
717 Visual mode.
718 .SH VISUAL MODE COMMANDS
719 .SS visual\-accept (default \f[CR]V\f[R])
720 Add the visual selection to the selection list, quit Visual mode and
721 return to Normal mode.
722 .SS visual\-unselect
723 Remove the visual selection from the selection list, quit Visual mode
724 and return to Normal mode.
725 .SS visual\-discard (default \f[CR]<esc>\f[R])
726 Discard the visual selection, quit Visual mode and return to Normal
727 mode.
728 .SS visual\-change (default \f[CR]o\f[R])
729 Go to the other end of the current Visual mode selection.
730 .SH COMMAND\-LINE MODE COMMANDS
731 The prompt character specifies which of the several Command\-line modes
732 you are in.
733 For example, the \f[CR]read\f[R] command takes you to the \f[CR]:\f[R]
734 mode.
735 .PP
736 When the cursor is at the first character in \f[CR]:\f[R] mode, pressing
737 one of the keys \f[CR]!\f[R], \f[CR]$\f[R], \f[CR]%\f[R], or
738 \f[CR]&\f[R] takes you to the corresponding mode.
739 You can go back with \f[CR]cmd\-delete\-back\f[R]
740 (\f[CR]<backspace>\f[R] by default).
741 .PP
742 The command line commands should be mostly compatible with readline
743 keybindings.
744 A character refers to a Unicode code point, a word consists of letters
745 and digits, and a Unix word consists of any non\-blank characters.
746 .SS cmd\-insert
747 Insert the character given in the argument.
748 This command is automatically called when required.
749 .SS cmd\-escape (default \f[CR]<esc>\f[R])
750 Quit Command\-line mode and return to Normal mode.
751 .SS cmd\-complete (default \f[CR]<tab>\f[R])
752 Autocomplete the current word.
753 .SS cmd\-menu\-complete, cmd\-menu\-complete\-back
754 Autocomplete the current word with the menu selection.
755 You need to assign keys to these commands (e.g.
756 \f[CR]cmap <tab> cmd\-menu\-complete; cmap <backtab> cmd\-menu\-complete\-back\f[R]).
757 You can use the assigned keys to display the menu and then cycle through
758 completion options.
759 .SS cmd\-menu\-accept
760 Accept the currently selected match in menu completion and close the
761 menu.
762 .SS cmd\-menu\-discard
763 Discard the currently selected match in menu completion and close the
764 menu.
765 .SS cmd\-enter (default \f[CR]<c\-j>\f[R] and \f[CR]<enter>\f[R])
766 Execute the current line.
767 .SS cmd\-interrupt (default \f[CR]<c\-c>\f[R])
768 Interrupt the current shell\-pipe command and return to the Normal mode.
769 .SS cmd\-history\-next (default \f[CR]<c\-n>\f[R] and \f[CR]<down>\f[R]), cmd\-history\-prev (default \f[CR]<c\-p>\f[R] and \f[CR]<up>\f[R])
770 Go to the next/previous entry in the command history.
771 If part of the command is already typed, then only matching entries will
772 be considered, and consecutive duplicate entries are skipped.
773 .SS cmd\-left (default \f[CR]<c\-b>\f[R] and \f[CR]<left>\f[R]), cmd\-right (default \f[CR]<c\-f>\f[R] and \f[CR]<right>\f[R])
774 Move the cursor to the left/right.
775 .SS cmd\-home (default \f[CR]<c\-a>\f[R] and \f[CR]<home>\f[R]), cmd\-end (default \f[CR]<c\-e>\f[R] and \f[CR]<end>\f[R])
776 Move the cursor to the beginning/end of the line.
777 .SS cmd\-delete (default \f[CR]<c\-d>\f[R] and \f[CR]<delete>\f[R])
778 Delete the next character.
779 .SS cmd\-delete\-back (default \f[CR]<backspace>\f[R])
780 Delete the previous character.
781 When at the beginning of a prompt, returns either to Normal mode or to
782 \f[CR]:\f[R] mode.
783 .SS cmd\-delete\-home (default \f[CR]<c\-u>\f[R]), cmd\-delete\-end (default \f[CR]<c\-k>\f[R])
784 Delete everything up to the beginning/end of the line.
785 .SS cmd\-delete\-unix\-word (default \f[CR]<c\-w>\f[R])
786 Delete the previous Unix word.
787 .SS cmd\-yank (default \f[CR]<c\-y>\f[R])
788 Paste the buffer content containing the last deleted item.
789 .SS cmd\-transpose (default \f[CR]<c\-t>\f[R])
790 Swap the characters before and after the cursor, then move the cursor
791 forward.
792 If there is no character after the cursor, swap the previous two
793 characters instead.
794 .SS cmd\-transpose\-word (default \f[CR]<a\-t>\f[R])
795 Swap the words before and after the cursor, then move the cursor
796 forward.
797 If there is no word after the cursor, swap the previous two words
798 instead.
799 .SS cmd\-word (default \f[CR]<a\-f>\f[R]), cmd\-word\-back (default \f[CR]<a\-b>\f[R])
800 Move the cursor by one word in the forward/backward direction.
801 .SS cmd\-delete\-word (default \f[CR]<a\-d>\f[R])
802 Delete the next word in the forward direction.
803 .SS cmd\-delete\-word\-back (default \f[CR]<a\-backspace>\f[R])
804 Delete the previous word in the backward direction.
805 .SS cmd\-capitalize\-word (default \f[CR]<a\-c>\f[R]), cmd\-uppercase\-word (default \f[CR]<a\-u>\f[R]), cmd\-lowercase\-word (default \f[CR]<a\-l>\f[R])
806 Capitalize/uppercase/lowercase the current word and jump to the next
807 word.
808 .SH SETTINGS
809 This section shows information about options to customize the behavior.
810 Character \f[CR]:\f[R] is used as the separator for list options
811 \f[CR][]int\f[R] and \f[CR][]string\f[R].
812 .SS anchorfind (bool) (default true)
813 When this option is enabled, the find command starts matching patterns
814 from the beginning of filenames, otherwise, it can match at an arbitrary
815 position.
816 .SS autoquit (bool) (default true)
817 Automatically quit the server when there are no clients left connected.
818 .SS borderfmt (string) (default \f[CR]\(rs033[0m\f[R])
819 Format string of border characters.
820 .SS borderstyle (string) (default \f[CR]box\f[R])
821 Border style used by \f[CR]drawbox\f[R].
822 .PP
823 The following styles are supported:
824 .IP
825 .EX
826 box outline around all panes and separators between them
827 roundbox like \(gabox\(ga, but with rounded outer corners
828 outline outline around all panes
829 roundoutline like \(gaoutline\(ga, but with rounded outer corners
830 separators separators between panes
831 .EE
832 .SS cleaner (string) (default \(ga\(ga) (not called if empty)
833 Set the path of a cleaner file.
834 The file should be executable.
835 This file is called if previewing is enabled, the previewer is set, and
836 the previously selected file has its preview cache disabled.
837 The following arguments are passed to the file, (1) current filename,
838 (2) width, (3) height, (4) horizontal position, (5) vertical position of
839 preview pane and (6) next filename to be previewed respectively.
840 Preview cleaning is disabled when the value of this option is left
841 empty.
842 .SS copyfmt (string) (default \f[CR]\(rs033[7;33m\f[R])
843 Format string of the indicator for files to be copied.
844 .SS cursoractivefmt (string) (default \f[CR]\(rs033[7m\f[R]), cursorparentfmt (string) (default \f[CR]\(rs033[7m\f[R]), cursorpreviewfmt (string) (default \f[CR]\(rs033[4m\f[R])
845 Format strings for highlighting the cursor.
846 \f[CR]cursoractivefmt\f[R] applies in the current directory pane,
847 \f[CR]cursorparentfmt\f[R] applies in panes that show parents of the
848 current directory, and \f[CR]cursorpreviewfmt\f[R] applies in panes that
849 preview directories.
850 .PP
851 The default is to make the active cursor and the parent directory cursor
852 inverted.
853 The preview cursor is underlined.
854 .PP
855 Some other possibilities to consider for the preview or parent cursors:
856 an empty string for no cursor, \f[CR]\(rs033[7;2m\f[R] for dimmed
857 inverted text (visibility varies by terminal), \f[CR]\(rs033[7;90m\f[R]
858 for inverted text with grey (aka \(dqbrightblack\(dq) background.
859 .PP
860 If the format string contains the characters \f[CR]%s\f[R], it is
861 interpreted as a format string for \f[CR]fmt.Sprintf\f[R].
862 Such a string should end with the terminal reset sequence.
863 For example, \f[CR]\(rs033[4m%s\(rs033[0m\f[R] has the same effect as
864 \f[CR]\(rs033[4m\f[R].
865 .SS cutfmt (string) (default \f[CR]\(rs033[7;31m\f[R])
866 Format string of the indicator for files to be cut.
867 .SS dircounts (bool) (default false)
868 When this option is enabled, directory sizes show the number of items
869 inside instead of the total size of the directory, which needs to be
870 calculated for each directory using \f[CR]calcdirsize\f[R].
871 This information needs to be calculated by reading the directory and
872 counting the items inside.
873 Therefore, this option is disabled by default for performance reasons.
874 This option only has an effect when \f[CR]info\f[R] has a
875 \f[CR]size\f[R] field and the pane is wide enough to show the
876 information.
877 9999 items are counted per directory at most, and bigger directories are
878 shown as \f[CR]9999+\f[R].
879 .SS dirfirst (bool) (default true)
880 Show directories first above regular files.
881 With \f[CR]dircounts\f[R] enabled, sorting by \f[CR]size\f[R] always
882 separates directories and files, regardless of \f[CR]dirfirst\f[R].
883 .SS dironly (bool) (default false)
884 Show only directories.
885 .SS dirpreviews (bool) (default false)
886 If enabled, directories will also be passed to the previewer script.
887 This allows custom previews for directories.
888 .SS drawbox (bool) (default false)
889 Draw borders around panes using box drawing characters.
890 .SS dupfilefmt (string) (default \f[CR]%f.\(ti%n\(ti\f[R])
891 Format string of filename when creating duplicate files.
892 With the default format, copying a file \f[CR]abc.txt\f[R] to the same
893 directory will result in a duplicate file called
894 \f[CR]abc.txt.\(ti1\(ti\f[R].
895 Special expansions are provided, \f[CR]%f\f[R] as the file name,
896 \f[CR]%b\f[R] for the base name (file name without extension),
897 \f[CR]%e\f[R] as the extension (including the dot) and \f[CR]%n\f[R] as
898 the number of duplicates.
899 .SS errorfmt (string) (default \f[CR]\(rs033[7;31;47m\f[R])
900 Format string of error messages shown in the bottom message line.
901 .PP
902 If the format string contains the characters \f[CR]%s\f[R], it is
903 interpreted as a format string for \f[CR]fmt.Sprintf\f[R].
904 Such a string should end with the terminal reset sequence.
905 For example, \f[CR]\(rs033[4m%s\(rs033[0m\f[R] has the same effect as
906 \f[CR]\(rs033[4m\f[R].
907 .SS filesep (string) (default \f[CR]\(rsn\f[R])
908 File separator used in environment variables \f[CR]fs\f[R],
909 \f[CR]fv\f[R] and \f[CR]fx\f[R].
910 .SS filtermethod (string) (default \f[CR]text\f[R])
911 How filter command patterns are treated.
912 Currently supported methods are \f[CR]text\f[R] (i.e.
913 string literals), \f[CR]glob\f[R] (i.e.
914 shell globs) and \f[CR]regex\f[R] (i.e.
915 regular expressions).
916 See \f[CR]SEARCHING FILES\f[R] for more details.
917 .SS findlen (int) (default 1)
918 Number of characters prompted for the find command.
919 When this value is set to 0, find command prompts until there is only a
920 single match left.
921 .SS hidden (bool) (default false)
922 Show hidden files.
923 On Unix systems, hidden files are determined by the value of
924 \f[CR]hiddenfiles\f[R].
925 On Windows, files with hidden attributes are also considered hidden
926 files.
927 .SS hiddenfiles ([]string) (default \f[CR].*\f[R] for Unix and \(ga\(ga for Windows)
928 List of hidden file glob patterns.
929 Patterns can be given as relative or absolute paths.
930 Globbing supports the usual special characters, \f[CR]*\f[R] to match
931 any sequence, \f[CR]?\f[R] to match any character, and \f[CR][...]\f[R]
932 or \f[CR][\(ha...]\f[R] to match character sets or ranges.
933 In addition, if a pattern starts with \f[CR]!\f[R], then its matches are
934 excluded from hidden files.
935 To add multiple patterns, use \f[CR]:\f[R] as a separator.
936 Example: \f[CR].*:lost+found:*.bak\f[R]
937 .SS history (bool) (default true)
938 Save command history.
939 .SS icons (bool) (default false)
940 Show icons before each item in the list.
941 .SS ifs (string) (default \(ga\(ga)
942 Sets \f[CR]IFS\f[R] variable in shell commands.
943 It works by adding the assignment to the beginning of the command string
944 as \f[CR]IFS=...; ...\f[R].
945 The reason is that \f[CR]IFS\f[R] variable is not inherited by the shell
946 for security reasons.
947 This method assumes a POSIX shell syntax so it can fail for non\-POSIX
948 shells.
949 This option has no effect when the value is left empty.
950 This option does not have any effect on Windows.
951 .SS ignorecase (bool) (default true)
952 Ignore case in search patterns.
953 See also \f[CR]sortignorecase\f[R].
954 .SS ignoredia (bool) (default true)
955 Ignore diacritics in search patterns.
956 See also \f[CR]sortignoredia\f[R].
957 .SS incfilter (bool) (default false)
958 Apply filter pattern after each keystroke during filtering.
959 .SS incsearch (bool) (default false)
960 Jump to the first match after each keystroke during searching.
961 .SS info ([]string) (default \(ga\(ga)
962 A list of information that is shown for directory items at the right
963 side of the pane.
964 .PP
965 The following information types are supported:
966 .IP
967 .EX
968 perm file permission
969 user user name
970 group group name
971 size file size
972 time time of last data modification
973 atime time of last access
974 btime time of file birth
975 ctime time of last status (inode) change
976 custom property defined via \(gaaddcustominfo\(ga (empty by default)
977 .EE
978 .PP
979 Information is only shown when the pane width is more than twice the
980 width of information.
981 .SS infotimefmtnew (string) (default \f[CR]Jan _2 15:04\f[R])
982 Format string of the file time shown in the info column when it matches
983 this year.
984 .SS infotimefmtold (string) (default \f[CR]Jan _2 2006\f[R])
985 Format string of the file time shown in the info column when it
986 doesn\(aqt match this year.
987 .SS menufmt (string) (default \f[CR]\(rs033[0m\f[R])
988 Format string of the menu.
989 .SS menuheaderfmt (string) (default \f[CR]\(rs033[1m\f[R])
990 Format string of the header row in the menu.
991 .SS menuselectfmt (string) (default \f[CR]\(rs033[7m\f[R])
992 Format string of the currently selected item in the menu.
993 .SS mergeindicators (bool) (default false)
994 When \f[CR]mergeindicators\f[R] is enabled, tag and selection indicators
995 are drawn in a single column to reduce the gap before filenames.
996 If a file is both tagged and selected, the tag uses the selection format
997 (e.g.
998 \f[CR]copyfmt\f[R]) instead of \f[CR]tagfmt\f[R].
999 .SS mouse (bool) (default false)
1000 Send mouse events as input.
1001 .SS number (bool) (default false)
1002 Show the position number for directory items on the left side of the
1003 pane.
1004 When the \f[CR]relativenumber\f[R] option is enabled, only the current
1005 line shows the absolute position and relative positions are shown for
1006 the rest.
1007 .SS numberfmt (string) (default \f[CR]\(rs033[33m\f[R]), numbercursorfmt (string) (default \(ga\(ga)
1008 Format strings for highlighting line numbers.
1009 \f[CR]numberfmt\f[R] applies to all lines.
1010 \f[CR]numbercursorfmt\f[R] applies to the cursor line and falls back to
1011 \f[CR]numberfmt\f[R] when left empty.
1012 .SS period (int) (default 0)
1013 Set the interval in seconds for periodic checks of directory updates.
1014 This works by periodically calling the \f[CR]load\f[R] command.
1015 Note that directories are already updated automatically in many cases.
1016 This option can be useful when there is an external process changing the
1017 displayed directory and you are not doing anything in lf.
1018 Periodic checks are disabled when the value of this option is set to
1019 zero.
1020 .SS preload (bool) (default false)
1021 Allow previews to be generated in advance using the \f[CR]previewer\f[R]
1022 script as the user navigates through the filesystem.
1023 .SS preserve ([]string) (default \f[CR]mode\f[R])
1024 List of attributes that are preserved when copying files.
1025 Currently supported attributes are \f[CR]mode\f[R] (i.e.
1026 access mode) and \f[CR]timestamps\f[R] (i.e.
1027 modification time and access time).
1028 Note that preserving other attributes like ownership or change/birth
1029 timestamps is desirable, but not portably supported in Go.
1030 .SS preview (bool) (default true)
1031 Show previews of files and directories at the rightmost pane.
1032 If the file has more lines than the preview pane, the rest of the lines
1033 are not read.
1034 Files are considered binary and displayed as \f[CR]binary\f[R] if the
1035 read portion contains a control character other than bell, backspace,
1036 tab, newline, vertical tab, form feed, carriage return, escape or
1037 delete.
1038 .SS previewer (string) (default \(ga\(ga) (not filtered if empty)
1039 Set the path of a previewer file to filter the content of regular files
1040 for previewing.
1041 The file should be executable.
1042 The following arguments are passed to the file, (1) current filename,
1043 (2) width, (3) height, (4) horizontal position, (5) vertical position,
1044 and (6) mode (\(dqpreview\(dq or \(dqpreload\(dq).
1045 SIGPIPE signal is sent when enough lines are read.
1046 If the previewer returns a non\-zero exit code, then the preview cache
1047 for the given file is disabled.
1048 This means that if the file is selected in the future, the previewer is
1049 called once again.
1050 Preview filtering is disabled and files are displayed as they are when
1051 the value of this option is left empty.
1052 If the \f[CR]preload\f[R] option is enabled, then this will be called
1053 with \f[CR]preload\f[R] as the mode when preloading file previews.
1054 Refer to the \c
1055 .UR https://github.com/gokcehan/lf/blob/master/doc.md#previewing-files
1056 PREVIEWING FILES section
1057 .UE \c
1058 \ for more information about how to configure custom previews.
1059 .SS promptfmt (string) (default \f[CR]\(rs033[32;1m%u\(at%h\(rs033[0m:\(rs033[34;1m%d\(rs033[0m\(rs033[1m%f\(rs033[0m\f[R])
1060 Format string of the prompt shown in the top line.
1061 .PP
1062 The following special expansions are supported:
1063 .IP
1064 .EX
1065 %f file name
1066 %h host name
1067 %u user name
1068 %w working directory
1069 %d working directory (with trailing path separator)
1070 %F current filter
1071 %S spacer to right\-align the following parts (can be used once)
1072 .EE
1073 .PP
1074 The home folder is shown as \f[CR]\(ti\f[R] in the working directory
1075 expansion.
1076 Directory names are automatically shortened to a single character
1077 starting from the leftmost parent when the prompt does not fit the
1078 screen.
1079 .SS ratios ([]int) (default \f[CR]1:2:3\f[R])
1080 List of ratios of pane widths.
1081 Number of items in the list determines the number of panes in the UI.
1082 When the \f[CR]preview\f[R] option is enabled, the rightmost number is
1083 used for the width of the preview pane.
1084 .SS relativenumber (bool) (default false)
1085 Show the position number relative to the current line.
1086 When \f[CR]number\f[R] is enabled, the current line shows the absolute
1087 position, otherwise nothing is shown.
1088 .SS reverse (bool) (default false)
1089 Reverse the direction of sort.
1090 .SS rulerfile (string) (default \(ga\(ga)
1091 Set the path of the ruler file.
1092 If not set, then a default template will be used for the ruler.
1093 Refer to the \c
1094 .UR https://github.com/gokcehan/lf/blob/master/doc.md#ruler
1095 RULER section
1096 .UE \c
1097 \ for more information about how the ruler file works.
1098 .SS rulerfmt (string) (default \(ga\(ga)
1099 Format string of the ruler shown in the bottom right corner.
1100 When set, it will be used along with \f[CR]statfmt\f[R] to draw the
1101 ruler, and \f[CR]rulerfile\f[R] will be ignored.
1102 However, using \f[CR]rulerfile\f[R] is preferred and this option is
1103 provided for backwards compatibility.
1104 .PP
1105 The following special expansions are supported:
1106 .IP
1107 .EX
1108 %a pressed keys
1109 %p progress of file operations
1110 %m number of files to be cut (moved)
1111 %c number of files to be copied
1112 %s number of selected files
1113 %v number of visually selected files
1114 %t number of shown files in the current directory
1115 %h number of hidden files in the current directory
1116 %f current filter
1117 %i cursor position
1118 %P scroll percentage
1119 %d amount of free disk space
1120 .EE
1121 .PP
1122 Additional expansions are provided for environment variables exported by
1123 lf, in the form \f[CR]%{lf_<name>}\f[R] (e.g.
1124 \f[CR]%{lf_selmode}\f[R]).
1125 This is useful for displaying the current settings.
1126 Expansions are also provided for user\-defined options, in the form
1127 \f[CR]%{lf_user_<name>}\f[R] (e.g.
1128 \f[CR]%{lf_user_foo}\f[R]).
1129 The \f[CR]|\f[R] character splits the format string into sections.
1130 Any section containing a failed expansion (result is a blank string) is
1131 discarded and not shown.
1132 .SS scrolloff (int) (default 0)
1133 Minimum number of offset lines shown at all times at the top and bottom
1134 of the screen when scrolling.
1135 The current line is kept in the middle when this option is set to a
1136 large value that is bigger than half the number of lines.
1137 A smaller offset can be used when the current file is close to the
1138 beginning or end of the list to show the maximum number of items.
1139 .SS searchmethod (string) (default \f[CR]text\f[R])
1140 How search command patterns are treated.
1141 Currently supported methods are \f[CR]text\f[R] (i.e.
1142 string literals), \f[CR]glob\f[R] (i.e.
1143 shell globs) and \f[CR]regex\f[R] (i.e.
1144 regular expressions).
1145 See \f[CR]SEARCHING FILES\f[R] for more details.
1146 .SS selectfmt (string) (default \f[CR]\(rs033[7;35m\f[R])
1147 Format string of the indicator for files that are selected.
1148 .SS selmode (string) (default \f[CR]all\f[R])
1149 Selection mode for commands.
1150 When set to \f[CR]all\f[R] it will use the selected files from all
1151 directories.
1152 When set to \f[CR]dir\f[R] it will only use the selected files in the
1153 current directory.
1154 .SS shell (string) (default \f[CR]sh\f[R] for Unix and \f[CR]cmd\f[R] for Windows)
1155 Shell executable to use for shell commands.
1156 Shell commands are executed as
1157 \f[CR]shell shellopts shellflag command \-\- arguments\f[R].
1158 .SS shellflag (string) (default \f[CR]\-c\f[R] for Unix and \f[CR]/c\f[R] for Windows)
1159 Command line flag used to pass shell commands.
1160 .SS shellopts ([]string) (default \(ga\(ga)
1161 List of shell options to pass to the shell executable.
1162 .SS showbinds (bool) (default true)
1163 Show bindings associated with pressed keys.
1164 .SS sizeunits (string) (default \f[CR]binary\f[R])
1165 Determines whether file sizes are displayed using binary units
1166 (\f[CR]1K\f[R] is 1024 bytes) or decimal units (\f[CR]1K\f[R] is 1000
1167 bytes).
1168 .SS smartcase (bool) (default true)
1169 Override \f[CR]ignorecase\f[R] option for searching when the pattern
1170 contains an uppercase character.
1171 This option has no effect when \f[CR]ignorecase\f[R] is disabled.
1172 .SS smartdia (bool) (default false)
1173 Override \f[CR]ignoredia\f[R] option when the pattern contains a
1174 character with diacritic.
1175 This option has no effect when \f[CR]ignoredia\f[R] is disabled.
1176 .SS sortby (string) (default \f[CR]natural\f[R])
1177 Sort type for directories.
1178 .PP
1179 The following sort types are supported:
1180 .IP
1181 .EX
1182 natural file name (track_2.flac comes before track_10.flac)
1183 name file name (track_10.flac comes before track_2.flac)
1184 ext file extension
1185 size file size
1186 time time of last data modification
1187 atime time of last access
1188 btime time of file birth
1189 ctime time of last status (inode) change
1190 custom property defined via \(gaaddcustominfo\(ga (empty by default)
1191 .EE
1192 .SS sortignorecase (bool) (default true)
1193 Ignore case when sorting.
1194 See also \f[CR]ignorecase\f[R].
1195 .SS sortignoredia (bool) (default true)
1196 Ignore diacritics when sorting.
1197 See also \f[CR]ignoredia\f[R].
1198 .SS statfmt (string) (default \f[CR]\(rs033[36m%p\(rs033[0m| %c| %u| %g| %S| %t| \-> %l\f[R])
1199 Format string of the file info shown in the bottom left corner.
1200 This option has no effect unless \f[CR]rulerfmt\f[R] is also set.
1201 Using \f[CR]rulerfile\f[R] is preferred and this option is provided for
1202 backwards compatibility.
1203 .PP
1204 The following special expansions are supported:
1205 .IP
1206 .EX
1207 %p file permission
1208 %c link count
1209 %u user name
1210 %g group name
1211 %s file size
1212 %S file size (left\-padded with spaces to a fixed width of 5 characters)
1213 %t time of last data modification
1214 %l link target
1215 %m current mode
1216 %M current mode (displaying \(gaNORMAL\(ga instead of a blank string in Normal mode)
1217 .EE
1218 .PP
1219 The \f[CR]|\f[R] character splits the format string into sections.
1220 Any section containing a failed expansion (result is a blank string) is
1221 discarded and not shown.
1222 .SS tabstop (int) (default 8)
1223 Number of space characters to show for horizontal tabulation (U+0009)
1224 character.
1225 .SS tagfmt (string) (default \f[CR]\(rs033[31m\f[R])
1226 Format string of the tags.
1227 .PP
1228 If the format string contains the characters \f[CR]%s\f[R], it is
1229 interpreted as a format string for \f[CR]fmt.Sprintf\f[R].
1230 Such a string should end with the terminal reset sequence.
1231 For example, \f[CR]\(rs033[4m%s\(rs033[0m\f[R] has the same effect as
1232 \f[CR]\(rs033[4m\f[R].
1233 .SS tempmarks (string) (default \(ga\(ga)
1234 Marks to be considered temporary (e.g.
1235 \f[CR]abc\f[R] refers to marks \f[CR]a\f[R], \f[CR]b\f[R], and
1236 \f[CR]c\f[R]).
1237 These marks are not synced to other clients and they are not saved in
1238 the bookmarks file.
1239 Note that the special bookmark \f[CR]\(aq\f[R] is always treated as
1240 temporary and it does not need to be specified.
1241 .SS terminalcursor (string) (default \f[CR]default\f[R])
1242 Set the appearance of the terminal cursor for prompts shown in the
1243 bottom line.
1244 Currently supported values are \f[CR]default\f[R], \f[CR]block\f[R],
1245 \f[CR]underline\f[R], \f[CR]bar\f[R], \f[CR]blinkblock\f[R],
1246 \f[CR]blinkunderline\f[R] and \f[CR]blinkbar\f[R].
1247 .SS timefmt (string) (default \f[CR]Mon Jan _2 15:04:05 2006\f[R])
1248 Format string of the file modification time shown in the bottom line.
1249 .SS truncatechar (string) (default \f[CR]\(ti\f[R])
1250 The truncate character that is shown at the end when the filename does
1251 not fit into the pane.
1252 .SS truncatepct (int) (default 100)
1253 When a filename is too long to be shown completely, the available space
1254 will be partitioned into two parts.
1255 \f[CR]truncatepct\f[R] is a percentage value between 0 and 100 that
1256 determines the size of the first part, which will be shown at the
1257 beginning of the filename.
1258 The second part uses the rest of the available space, and will be shown
1259 at the end of the filename.
1260 Both parts are separated by the truncation character
1261 (\f[CR]truncatechar\f[R]).
1262 Truncation is not applied to the file extension.
1263 .PP
1264 For example, with the filename \f[CR]very_long_filename.txt\f[R]:
1265 .IP \(bu 2
1266 \f[CR]set truncatepct 100\f[R] \-> \f[CR]very_long_filena\(ti.txt\f[R]
1267 (default)
1268 .IP \(bu 2
1269 \f[CR]set truncatepct 50\f[R] \-> \f[CR]very_lon\(tifilename.txt\f[R]
1270 .IP \(bu 2
1271 \f[CR]set truncatepct 0\f[R] \-> \f[CR]\(tiry_long_filename.txt\f[R]
1272 .SS visualfmt (string) (default \f[CR]\(rs033[7;36m\f[R])
1273 Format string of the indicator for files that are visually selected.
1274 .SS waitmsg (string) (default \f[CR]Press any key to continue\f[R])
1275 String shown after commands of shell\-wait type.
1276 .SS watch (bool) (default false)
1277 Watch the filesystem for changes using \f[CR]fsnotify\f[R] to
1278 automatically refresh file information.
1279 FUSE is currently not supported due to limitations in
1280 \f[CR]fsnotify\f[R].
1281 .SS wrapscan (bool) (default true)
1282 Searching can wrap around the file list.
1283 .SS wrapscroll (bool) (default false)
1284 Scrolling can wrap around the file list.
1285 .SS user_{option} (string) (default none)
1286 Any option that is prefixed with \f[CR]user_\f[R] is a user\-defined
1287 option and can be set to any string.
1288 Inside a user\-defined command, the value will be provided in the
1289 \f[CR]lf_user_{option}\f[R] environment variable.
1290 These options are not used by lf and are not persisted.
1291 .SH ENVIRONMENT VARIABLES
1292 The following variables are exported for shell commands: These are
1293 referred to with a \f[CR]$\f[R] prefix on POSIX shells (e.g.
1294 \f[CR]$f\f[R]), between \f[CR]%\f[R] characters on Windows cmd (e.g.
1295 \f[CR]%f%\f[R]), and with a \f[CR]$env:\f[R] prefix on Windows
1296 PowerShell (e.g.
1297 \f[CR]$env:f\f[R]).
1298 .SS f
1299 Current file selection as a full path.
1300 .SS fs
1301 Selected file(s) separated with the value of \f[CR]filesep\f[R] option
1302 as full path(s).
1303 .SS fv
1304 Visually selected file(s) separated with the value of \f[CR]filesep\f[R]
1305 option as full path(s).
1306 .SS fx
1307 Selected file(s) (i.e.
1308 \f[CR]fs\f[R], never \f[CR]fv\f[R]) if there are any selected files,
1309 otherwise current file selection (i.e.
1310 \f[CR]f\f[R]).
1311 .SS id
1312 Id of the running client.
1313 .SS PWD
1314 Present working directory.
1315 .SS OLDPWD
1316 Initial working directory.
1317 .SS LF_LEVEL
1318 The value of this variable is set to the current nesting level when you
1319 run lf from a shell spawned inside lf.
1320 You can add the value of this variable to your shell prompt to make it
1321 clear that your shell runs inside lf.
1322 For example, with POSIX shells, you can use
1323 \f[CR][ \-n \(dq$LF_LEVEL\(dq ] && PS1=\(dq$PS1\(dq\(dq(lf level: $LF_LEVEL) \(dq\f[R]
1324 in your shell configuration file (e.g.
1325 \f[CR]\(ti/.bashrc\f[R]).
1326 .SS OPENER
1327 If this variable is set in the environment, use the same value.
1328 Otherwise, this is set to \f[CR]start\f[R] in Windows, \f[CR]open\f[R]
1329 in macOS, \f[CR]xdg\-open\f[R] in others.
1330 .SS EDITOR
1331 If VISUAL is set in the environment, use its value.
1332 Otherwise, use the value of the environment variable EDITOR.
1333 If neither variable is set, this is set to \f[CR]vi\f[R] on Unix,
1334 \f[CR]notepad\f[R] in Windows.
1335 .SS PAGER
1336 If this variable is set in the environment, use the same value.
1337 Otherwise, this is set to \f[CR]less\f[R] on Unix, \f[CR]more\f[R] in
1338 Windows.
1339 .SS SHELL
1340 If this variable is set in the environment, use the same value.
1341 Otherwise, this is set to \f[CR]sh\f[R] on Unix, \f[CR]cmd\f[R] in
1342 Windows.
1343 .SS lf
1344 Absolute path to the currently running lf binary, if it can be found.
1345 Otherwise, this is set to the string \f[CR]lf\f[R].
1346 .SS lf_{option}
1347 Value of the {option}.
1348 .SS lf_user_{option}
1349 Value of the user_{option}.
1350 .SS lf_flag_{flag}
1351 Value of the command line {flag}.
1352 .SS lf_width, lf_height
1353 Width/Height of the terminal.
1354 .SS lf_count
1355 Value of the count associated with the current command.
1356 .SS lf_mode
1357 Current mode that \f[CR]lf\f[R] is operating in.
1358 This is useful for customizing keybindings depending on what the current
1359 mode is.
1360 Possible values are \f[CR]compmenu\f[R], \f[CR]delete\f[R],
1361 \f[CR]rename\f[R], \f[CR]filter\f[R], \f[CR]find\f[R], \f[CR]mark\f[R],
1362 \f[CR]search\f[R], \f[CR]command\f[R], \f[CR]shell\f[R], \f[CR]pipe\f[R]
1363 (when running a shell\-pipe command), \f[CR]normal\f[R],
1364 \f[CR]visual\f[R] and \f[CR]unknown\f[R].
1365 .SH SPECIAL COMMANDS
1366 This section shows information about special shell commands.
1367 .SS open
1368 This shell command can be defined to override the default
1369 \f[CR]open\f[R] command when the current file is not a directory.
1370 .SS paste
1371 This shell command can be defined to override the default
1372 \f[CR]paste\f[R] command.
1373 .SS rename
1374 This shell command can be defined to override the default
1375 \f[CR]rename\f[R] command.
1376 .SS delete
1377 This shell command can be defined to override the default
1378 \f[CR]delete\f[R] command.
1379 .SS pre\-cd
1380 This shell command can be defined to be executed before changing a
1381 directory.
1382 .SS on\-cd
1383 This shell command can be defined to be executed after changing a
1384 directory.
1385 .SS on\-load
1386 This shell command can be defined to be executed after loading a
1387 directory.
1388 It provides the files inside the directory as arguments.
1389 .SS on\-focus\-gained
1390 This shell command can be defined to be executed when the terminal gains
1391 focus.
1392 .SS on\-focus\-lost
1393 This shell command can be defined to be executed when the terminal loses
1394 focus.
1395 .SS on\-init
1396 This shell command can be defined to be executed after initializing and
1397 connecting to the server.
1398 .SS on\-select
1399 This shell command can be defined to be executed after the selection
1400 changes.
1401 .SS on\-redraw
1402 This shell command can be defined to be executed after the screen is
1403 redrawn or if the terminal is resized.
1404 .SS on\-quit
1405 This shell command can be defined to be executed before quitting.
1406 .SH PREFIXES
1407 The following command prefixes are used by lf:
1408 .IP
1409 .EX
1410 : read (default) built\-in/custom command
1411 $ shell shell command
1412 % shell\-pipe shell command running with the UI
1413 ! shell\-wait shell command waiting for a key press
1414 & shell\-async shell command running asynchronously
1415 .EE
1416 .PP
1417 The same evaluator is used for the command line and the configuration
1418 file for reading shell commands.
1419 The difference is that prefixes are not necessary in the command line.
1420 Instead, different modes are provided to read corresponding commands.
1421 These modes are mapped to the prefix keys above by default.
1422 Visual mode mappings are defined the same way Normal mode mappings are
1423 defined.
1424 .SH SYNTAX
1425 Characters from \f[CR]#\f[R] to newline are comments and ignored:
1426 .IP
1427 .EX
1428 # comments start with \(ga#\(ga
1429 .EE
1430 .PP
1431 The following commands (\f[CR]set\f[R], \f[CR]setlocal\f[R],
1432 \f[CR]map\f[R], \f[CR]nmap\f[R], \f[CR]vmap\f[R], \f[CR]cmap\f[R], and
1433 \f[CR]cmd\f[R]) are used for configuration.
1434 .PP
1435 Command \f[CR]set\f[R] is used to set an option which can be a boolean,
1436 integer, or string:
1437 .IP
1438 .EX
1439 set hidden # boolean enable
1440 set hidden true # boolean enable
1441 set nohidden # boolean disable
1442 set hidden false # boolean disable
1443 set hidden! # boolean toggle
1444 set scrolloff 10 # integer value
1445 set sortby time # string value without quotes
1446 set sortby \(aqtime\(aq # string value with single quotes (whitespace)
1447 set sortby \(dqtime\(dq # string value with double quotes (backslash escapes)
1448 .EE
1449 .PP
1450 Command \f[CR]setlocal\f[R] is used to set a local option for a
1451 directory which can be a boolean or string.
1452 Currently supported local options are \f[CR]dircounts\f[R],
1453 \f[CR]dirfirst\f[R], \f[CR]dironly\f[R], \f[CR]hidden\f[R],
1454 \f[CR]info\f[R], \f[CR]reverse\f[R], \f[CR]sortby\f[R],
1455 \f[CR]sortignorecase\f[R] and \f[CR]sortignoredia\f[R].
1456 .IP
1457 .EX
1458 setlocal /foo/bar hidden # boolean enable
1459 setlocal /foo/bar hidden true # boolean enable
1460 setlocal /foo/bar nohidden # boolean disable
1461 setlocal /foo/bar hidden false # boolean disable
1462 setlocal /foo/bar hidden! # boolean toggle
1463 setlocal /foo/bar sortby time # string value without quotes
1464 setlocal /foo/bar sortby \(aqtime\(aq # string value with single quotes (whitespace)
1465 setlocal /foo/bar sortby \(dqtime\(dq # string value with double quotes (backslash escapes)
1466 .EE
1467 .PP
1468 Command \f[CR]map\f[R] is used to bind a key in Normal and Visual mode
1469 to a command which can be a built\-in command, custom command, or shell
1470 command:
1471 .IP
1472 .EX
1473 map gh cd \(ti # built\-in command
1474 map D trash # custom command
1475 map i $less $f # shell command
1476 map U !du \-csh * # waiting shell command
1477 .EE
1478 .PP
1479 Command \f[CR]nmap\f[R] does the same but for Normal mode only.
1480 .PP
1481 Command \f[CR]vmap\f[R] does the same but for Visual mode only.
1482 .PP
1483 Overview of which map command works in which mode:
1484 .IP
1485 .EX
1486 map Normal, Visual
1487 nmap Normal
1488 vmap Visual
1489 cmap Command\-line
1490 .EE
1491 .PP
1492 Command \f[CR]cmap\f[R] is used to bind a key on the command line to a
1493 command line command or any other command:
1494 .IP
1495 .EX
1496 cmap <c\-g> cmd\-escape
1497 cmap <a\-i> set incsearch!
1498 .EE
1499 .PP
1500 You can delete an existing binding by leaving the expression empty:
1501 .IP
1502 .EX
1503 map gh # deletes \(aqgh\(aq mapping in Normal and Visual mode
1504 nmap v # deletes \(aqv\(aq mapping in Normal mode
1505 vmap o # deletes \(aqo\(aq mapping in Visual mode
1506 cmap <c\-g> # deletes \(aq<c\-g>\(aq mapping
1507 .EE
1508 .PP
1509 Command \f[CR]cmd\f[R] is used to define a custom command:
1510 .IP
1511 .EX
1512 cmd usage $du \-h \-d1 | less
1513 .EE
1514 .PP
1515 You can delete an existing command by leaving the expression empty:
1516 .IP
1517 .EX
1518 cmd trash # deletes \(aqtrash\(aq command
1519 .EE
1520 .PP
1521 If there is no prefix then \f[CR]:\f[R] is assumed:
1522 .IP
1523 .EX
1524 map zt set info time
1525 .EE
1526 .PP
1527 An explicit \f[CR]:\f[R] can be provided to group statements until a
1528 newline which is especially useful for \f[CR]map\f[R] and \f[CR]cmd\f[R]
1529 commands:
1530 .IP
1531 .EX
1532 map st :set sortby time; set info time
1533 .EE
1534 .PP
1535 If you need multiline you can wrap statements in \f[CR]{{\f[R] and
1536 \f[CR]}}\f[R] after the proper prefix.
1537 .IP
1538 .EX
1539 map st :{{
1540 set sortby time
1541 set info time
1542 }}
1543 .EE
1544 .SH KEY MAPPINGS
1545 Regular keys are assigned to a command with the usual syntax:
1546 .IP
1547 .EX
1548 map a down
1549 .EE
1550 .PP
1551 Keys combined with the Shift key simply use the uppercase letter:
1552 .IP
1553 .EX
1554 map A down
1555 .EE
1556 .PP
1557 Special keys are written in between \f[CR]<\f[R] and \f[CR]>\f[R]
1558 characters and always use lowercase letters:
1559 .IP
1560 .EX
1561 map <enter> down
1562 .EE
1563 .PP
1564 Angle brackets can be assigned with their special names:
1565 .IP
1566 .EX
1567 map <lt> down
1568 map <gt> down
1569 .EE
1570 .PP
1571 Function keys are prefixed with an \f[CR]f\f[R] character:
1572 .IP
1573 .EX
1574 map <f\-1> down
1575 .EE
1576 .PP
1577 Keys combined with the Ctrl key are prefixed with a \f[CR]c\f[R]
1578 character:
1579 .IP
1580 .EX
1581 map <c\-a> down
1582 .EE
1583 .PP
1584 Keys combined with the Alt key are assigned in two different ways
1585 depending on the behavior of your terminal.
1586 Older terminals (e.g.
1587 xterm) may set the 8th bit of a character when the Alt key is pressed.
1588 On these terminals, you can use the corresponding byte for the mapping:
1589 .IP
1590 .EX
1591 map á down
1592 .EE
1593 .PP
1594 Newer terminals (e.g.
1595 gnome\-terminal) may prefix the key with an escape character when the
1596 Alt key is pressed.
1597 lf uses the escape delaying mechanism to recognize Alt keys in these
1598 terminals (delay is 100ms).
1599 On these terminals, keys combined with the Alt key are prefixed with an
1600 \f[CR]a\f[R] character:
1601 .IP
1602 .EX
1603 map <a\-a> down
1604 .EE
1605 .PP
1606 It is possible to combine special keys with modifiers:
1607 .IP
1608 .EX
1609 map <a\-enter> down
1610 .EE
1611 .PP
1612 Combining multiple modifiers (e.g.
1613 \f[CR]Ctrl+Shift+Space\f[R]) is not supported.
1614 .PP
1615 Note that lf\(aqs key mapping syntax is similar to Vim\(aqs, but not
1616 identical.
1617 Some special keys and modifiers use different names and separators, and
1618 key names are matched literally (i.e.
1619 no case\-folding, no aliases), so some familiar forms will not work:
1620 .IP
1621 .EX
1622 map <enter> down # not <Enter>, <Return> or <CR>
1623 map <f\-1> down # not <F1>
1624 map <a\-j> down # not <A\-j> or <M\-j> (Meta)
1625 map <m\-2> down # not <RightMouse>
1626 map <m\-up> down # not <ScrollWheelUp>
1627 .EE
1628 .PP
1629 WARNING: Some key combinations will likely be intercepted by your OS,
1630 window manager, or terminal.
1631 Other key combinations may not be distinguishable by lf, depending on
1632 how the terminal reports them (e.g.
1633 \f[CR]Ctrl+h\f[R] may be reported as \f[CR]backspace\f[R] instead).
1634 The easiest way to find out the name of a key combination and whether it
1635 will work on your system is to press the key while lf is running and
1636 read the name from the \f[CR]unknown mapping\f[R] error.
1637 .PP
1638 Mouse buttons are prefixed with an \f[CR]m\f[R] character:
1639 .IP
1640 .EX
1641 map <m\-1> down # primary
1642 map <m\-2> down # secondary
1643 map <m\-3> down # middle
1644 map <m\-4> down # thumb next
1645 map <m\-5> down # thumb prev
1646 map <m\-6> down
1647 map <m\-7> down
1648 map <m\-8> down
1649 .EE
1650 .PP
1651 Mouse wheel events are also prefixed with an \f[CR]m\f[R] character:
1652 .IP
1653 .EX
1654 map <m\-up> down
1655 map <m\-down> down
1656 map <m\-left> down
1657 map <m\-right> down
1658 .EE
1659 .SH PUSH MAPPINGS
1660 The usual way to map a key sequence is to assign it to a named or
1661 unnamed command.
1662 While this provides a clean way to remap built\-in keys as well as other
1663 commands, it can be limiting at times.
1664 For this reason, the \f[CR]push\f[R] command is provided by lf.
1665 This command is used to simulate key pushes given as its arguments.
1666 You can \f[CR]map\f[R] a key to a \f[CR]push\f[R] command with an
1667 argument to create various keybindings.
1668 .PP
1669 This is mainly useful for two purposes.
1670 First, it can be used to map a command with a command count:
1671 .IP
1672 .EX
1673 map <c\-j> push 10j
1674 .EE
1675 .PP
1676 Second, it can be used to avoid typing the name when a command takes
1677 arguments:
1678 .IP
1679 .EX
1680 map r push :rename<space>
1681 .EE
1682 .PP
1683 One thing to be careful of is that since the \f[CR]push\f[R] command
1684 works with keys instead of commands it is possible to accidentally
1685 create recursive bindings:
1686 .IP
1687 .EX
1688 map j push 2j
1689 .EE
1690 .PP
1691 These types of bindings create a deadlock when executed.
1692 .SH SHELL COMMANDS
1693 Regular shell commands are the most basic command type that is useful
1694 for many purposes.
1695 For example, we can write a shell command to move the selected file(s)
1696 to trash.
1697 A first attempt to write such a command may look like this:
1698 .IP
1699 .EX
1700 cmd trash ${{
1701 mkdir \-p \(ti/.trash
1702 if [ \-z \(dq$fs\(dq ]; then
1703 mv \(dq$f\(dq \(ti/.trash
1704 else
1705 IFS=\(dq$(printf \(aq\(rsn\(rst\(aq)\(dq; mv $fs \(ti/.trash
1706 fi
1707 }}
1708 .EE
1709 .PP
1710 We check \f[CR]$fs\f[R] to see if there are any selected files.
1711 Otherwise, we just delete the current file.
1712 Since this is such a common pattern, a separate \f[CR]$fx\f[R] variable
1713 is provided.
1714 We can use this variable to get rid of the conditional:
1715 .IP
1716 .EX
1717 cmd trash ${{
1718 mkdir \-p \(ti/.trash
1719 IFS=\(dq$(printf \(aq\(rsn\(rst\(aq)\(dq; mv $fx \(ti/.trash
1720 }}
1721 .EE
1722 .PP
1723 The trash directory is checked each time the command is executed.
1724 We can move it outside of the command so it would only run once at
1725 startup:
1726 .IP
1727 .EX
1728 ${{ mkdir \-p \(ti/.trash }}
1729
1730 cmd trash ${{ IFS=\(dq$(printf \(aq\(rsn\(rst\(aq)\(dq; mv $fx \(ti/.trash }}
1731 .EE
1732 .PP
1733 Since these are one\-liners, we can drop \f[CR]{{\f[R] and
1734 \f[CR]}}\f[R]:
1735 .IP
1736 .EX
1737 $mkdir \-p \(ti/.trash
1738
1739 cmd trash $IFS=\(dq$(printf \(aq\(rsn\(rst\(aq)\(dq; mv $fx \(ti/.trash
1740 .EE
1741 .PP
1742 Finally, note that we set the \f[CR]IFS\f[R] variable manually in these
1743 commands.
1744 Instead, we could use the \f[CR]ifs\f[R] option to set it for all shell
1745 commands (i.e.
1746 \f[CR]set ifs \(dq\(rsn\(dq\f[R]).
1747 This can be especially useful for interactive use (e.g.
1748 \f[CR]$rm $f\f[R] or \f[CR]$rm $fs\f[R] would simply work).
1749 This option is not set by default as it can behave unexpectedly for new
1750 users.
1751 However, use of this option is highly recommended and it is assumed in
1752 the rest of the documentation.
1753 .SH PIPING SHELL COMMANDS
1754 Regular shell commands have some limitations in some cases.
1755 When an output or error message is given and the command exits
1756 afterwards, the UI is immediately resumed and there is no way to see the
1757 message without dropping to shell again.
1758 Also, even when there is no output or error, the UI still needs to be
1759 paused while the command is running.
1760 This can cause flickering on the screen for short commands and similar
1761 distractions for longer commands.
1762 .PP
1763 Instead of pausing the UI, piping shell commands connect stdin, stdout,
1764 and stderr of the command to the statline at the bottom of the UI.
1765 This can be useful for programs following the Unix philosophy to give no
1766 output in the success case, and brief error messages or prompts in other
1767 cases.
1768 .PP
1769 For example, the following rename command prompts for overwrite in the
1770 statline if there is an existing file with the given name:
1771 .IP
1772 .EX
1773 cmd rename %mv \-i $f $1
1774 .EE
1775 .PP
1776 You can also output error messages in the command and they will show up
1777 in the statline.
1778 For example, an alternative rename command may look like this:
1779 .IP
1780 .EX
1781 cmd rename %[ \-e $1 ] && printf \(dqfile exists\(dq || mv $f $1
1782 .EE
1783 .PP
1784 Note that input is line buffered and output and error are byte buffered.
1785 .SH WAITING SHELL COMMANDS
1786 Waiting shell commands are similar to regular shell commands except that
1787 they wait for a key press when the command is finished.
1788 These can be useful to see the output of a program before the UI is
1789 resumed.
1790 Waiting shell commands are more appropriate than piping shell commands
1791 when the command is verbose and the output is best displayed as
1792 multiline.
1793 .SH ASYNCHRONOUS SHELL COMMANDS
1794 Asynchronous shell commands are used to start a command in the
1795 background and then resume operation without waiting for the command to
1796 finish.
1797 Stdin, stdout, and stderr of the command are neither connected to the
1798 terminal nor the UI.
1799 .SH REMOTE COMMANDS
1800 One of the more advanced features in lf is remote commands.
1801 All clients connect to a server on startup.
1802 It is possible to send commands to all or any of the connected clients
1803 over the common server.
1804 This is used internally to notify file selection changes to other
1805 clients.
1806 .PP
1807 To use this feature, you need to use a client which supports
1808 communicating with a Unix domain socket.
1809 OpenBSD implementation of netcat (nc) is one such example.
1810 You can use it to send a command to the socket file:
1811 .IP
1812 .EX
1813 echo \(aqsend echo hello world\(aq | nc \-U ${XDG_RUNTIME_DIR:\-/tmp/lf\-$(id \-u)}/lf.sock
1814 .EE
1815 .PP
1816 Since such a client may not be available everywhere, lf comes bundled
1817 with a command line flag to be used as such.
1818 When using lf, you do not need to specify the address of the socket
1819 file.
1820 This is the recommended way of using remote commands since it is shorter
1821 and immune to socket file address changes:
1822 .IP
1823 .EX
1824 lf \-remote \(aqsend echo hello world\(aq
1825 .EE
1826 .PP
1827 In this command \f[CR]send\f[R] is used to send the rest of the string
1828 as a command to all connected clients.
1829 You can optionally give it an ID number to send a command to a single
1830 client:
1831 .IP
1832 .EX
1833 lf \-remote \(aqsend 1234 echo hello world\(aq
1834 .EE
1835 .PP
1836 All clients have a unique ID number but you may not be aware of the ID
1837 number when you are writing a command.
1838 For this purpose, an \f[CR]$id\f[R] variable is exported to the
1839 environment for shell commands.
1840 The value of this variable is set to the process ID of the client.
1841 You can use it to send a remote command from a client to the server
1842 which in return sends a command back to itself.
1843 So now you can display a message in the current client by calling the
1844 following in a shell command:
1845 .IP
1846 .EX
1847 lf \-remote \(dqsend $id echo hello world\(dq
1848 .EE
1849 .PP
1850 Since lf does not have control flow syntax, remote commands are used for
1851 such needs.
1852 For example, you can configure the number of columns in the UI with
1853 respect to the terminal width as follows:
1854 .IP
1855 .EX
1856 cmd recol %{{
1857 if [ $lf_width \-le 80 ]; then
1858 lf \-remote \(dqsend $id set ratios 1:2\(dq
1859 elif [ $lf_width \-le 160 ]; then
1860 lf \-remote \(dqsend $id set ratios 1:2:3\(dq
1861 else
1862 lf \-remote \(dqsend $id set ratios 1:2:3:5\(dq
1863 fi
1864 }}
1865 .EE
1866 .PP
1867 In addition, the \f[CR]query\f[R] command can be used to obtain
1868 information about a specific lf instance by providing its ID:
1869 .IP
1870 .EX
1871 lf \-remote \(dqquery $id maps\(dq
1872 .EE
1873 .PP
1874 The following types of information are supported:
1875 .IP
1876 .EX
1877 maps list of mappings created by the \(aqmap\(aq, \(aqnmap\(aq and \(aqvmap\(aq command
1878 nmaps list of mappings created by the \(aqnmap\(aq and \(aqmap\(aq command
1879 vmaps list of mappings created by the \(aqvmap\(aq and \(aqmap\(aq command
1880 cmaps list of mappings created by the \(aqcmap\(aq command
1881 cmds list of commands created by the \(aqcmd\(aq command
1882 jumps contents of the jump list, showing previously visited locations
1883 history list of previously executed commands on the command line
1884 files list of files in the currently open directory as displayed by lf, empty if dir is still loading
1885 .EE
1886 .PP
1887 When listing mappings the characters in the first column are:
1888 .IP
1889 .EX
1890 n Normal
1891 v Visual
1892 c Command\-line
1893 .EE
1894 .PP
1895 This is useful for scripting actions based on the internal state of lf.
1896 For example, to select a previous command using fzf and execute it:
1897 .IP
1898 .EX
1899 map <a\-h> ${{
1900 clear
1901 cmd=$(
1902 lf \-remote \(dqquery $id history\(dq |
1903 awk \-F\(aq\(rst\(aq \(aqNR > 1 { print $NF}\(aq |
1904 sort \-u |
1905 fzf \-\-reverse \-\-prompt=\(aqExecute command: \(aq
1906 )
1907 lf \-remote \(dqsend $id $cmd\(dq
1908 }}
1909 .EE
1910 .PP
1911 The \f[CR]list\f[R] command prints the IDs of all currently connected
1912 clients:
1913 .IP
1914 .EX
1915 lf \-remote \(aqlist\(aq
1916 .EE
1917 .PP
1918 There is also a \f[CR]quit\f[R] command to quit the server when there
1919 are no connected clients left, and a \f[CR]quit!\f[R] command to force
1920 quit the server by closing client connections first:
1921 .IP
1922 .EX
1923 lf \-remote \(aqquit\(aq
1924 lf \-remote \(aqquit!\(aq
1925 .EE
1926 .PP
1927 Lastly, the commands \f[CR]conn\f[R] and \f[CR]drop\f[R] connect or
1928 disconnect ID to/from the server:
1929 .IP
1930 .EX
1931 lf \-remote \(aqconn $id\(aq
1932 lf \-remote \(aqdrop $id\(aq
1933 .EE
1934 .PP
1935 These are internal and generally not needed by users.
1936 .SH FILE OPERATIONS
1937 lf uses its own built\-in copy and move operations by default.
1938 These are implemented as asynchronous operations and progress is shown
1939 in the bottom ruler.
1940 These commands do not overwrite existing files or directories with the
1941 same name.
1942 Instead, a suffix that is compatible with the
1943 \f[CR]\-\-backup=numbered\f[R] option in GNU cp is added to the new
1944 files or directories.
1945 Only file modes and (some) timestamps can be preserved (see
1946 \f[CR]preserve\f[R] option), all other attributes are ignored including
1947 ownership, context, and xattr.
1948 Special files such as character and block devices, named pipes, and
1949 sockets are skipped and links are not followed.
1950 Moving is performed using the rename operation of the underlying OS.
1951 For cross\-device moving, lf falls back to copying and then deletes the
1952 original files if there are no errors.
1953 Operation errors are shown in the message line as well as the log file
1954 and they do not prematurely terminate the corresponding file operation.
1955 .PP
1956 File operations can be performed on the currently selected file or on
1957 multiple files by selecting them first.
1958 When you \f[CR]copy\f[R] a file, lf doesn\(aqt actually copy the file on
1959 the disk, but only records its name to a file.
1960 The actual file copying takes place when you \f[CR]paste\f[R].
1961 Similarly \f[CR]paste\f[R] after a \f[CR]cut\f[R] operation moves the
1962 file.
1963 .PP
1964 You can customize copy and move operations by defining a
1965 \f[CR]paste\f[R] command.
1966 This is a special command that is called when it is defined instead of
1967 the built\-in implementation.
1968 You can use the following example as a starting point:
1969 .IP
1970 .EX
1971 cmd paste %{{
1972 load=$(cat \(ti/.local/share/lf/files)
1973 mode=$(echo \(dq$load\(dq | sed \-n \(aq1p\(aq)
1974 list=$(echo \(dq$load\(dq | sed \(aq1d\(aq)
1975 if [ $mode = \(aqcopy\(aq ]; then
1976 cp \-R $list .
1977 elif [ $mode = \(aqmove\(aq ]; then
1978 mv $list .
1979 rm \(ti/.local/share/lf/files
1980 lf \-remote \(aqsend clear\(aq
1981 fi
1982 }}
1983 .EE
1984 .PP
1985 Some useful things to be considered are to use the backup
1986 (\f[CR]\-\-backup\f[R]) and/or preserve attributes (\f[CR]\-a\f[R])
1987 options with \f[CR]cp\f[R] and \f[CR]mv\f[R] commands if they support it
1988 (i.e.
1989 GNU implementation), change the command type to asynchronous, or use
1990 \f[CR]rsync\f[R] command with progress bar option for copying and feed
1991 the progress to the client periodically with remote \f[CR]echo\f[R]
1992 calls.
1993 .PP
1994 By default, lf does not assign \f[CR]delete\f[R] command to a key to
1995 protect new users.
1996 You can customize file deletion by defining a \f[CR]delete\f[R] command.
1997 You can also assign a key to this command if you like.
1998 An example command to move selected files to a trash folder and remove
1999 files completely after a prompt is provided in the example configuration
2000 file.
2001 .SH SEARCHING FILES
2002 There are two mechanisms implemented in lf to search a file in the
2003 current directory.
2004 Searching is the traditional method to move the selection to a file
2005 matching a given pattern.
2006 Finding is an alternative way to search for a pattern possibly using
2007 fewer keystrokes.
2008 .PP
2009 The searching mechanism is implemented with commands \f[CR]search\f[R]
2010 (default \f[CR]/\f[R]), \f[CR]search\-back\f[R] (default \f[CR]?\f[R]),
2011 \f[CR]search\-next\f[R] (default \f[CR]n\f[R]), and
2012 \f[CR]search\-prev\f[R] (default \f[CR]N\f[R]).
2013 You can set \f[CR]searchmethod\f[R] to \f[CR]glob\f[R] to match using a
2014 glob pattern.
2015 Globbing supports \f[CR]*\f[R] to match any sequence, \f[CR]?\f[R] to
2016 match any character, and \f[CR][...]\f[R] or \f[CR][\(ha...]\f[R] to
2017 match character sets or ranges.
2018 You can set \f[CR]searchmethod\f[R] to \f[CR]regex\f[R] to match using a
2019 regex pattern.
2020 For a full overview of Go\(aqs RE2 syntax, see \c
2021 .UR https://pkg.go.dev/regexp/syntax
2022 .UE \c
2023 \&.
2024 You can enable \f[CR]incsearch\f[R] option to jump to the current match
2025 at each keystroke while typing.
2026 In this mode, you can either use \f[CR]cmd\-enter\f[R] to accept the
2027 search or use \f[CR]cmd\-escape\f[R] to cancel the search.
2028 You can also map some other commands with \f[CR]cmap\f[R] to accept the
2029 search and execute the command immediately afterwards.
2030 For example, you can use the right arrow key to finish the search and
2031 open the selected file with the following mapping:
2032 .IP
2033 .EX
2034 cmap <right> :cmd\-enter; open
2035 .EE
2036 .PP
2037 The finding mechanism is implemented with commands \f[CR]find\f[R]
2038 (default \f[CR]f\f[R]), \f[CR]find\-back\f[R] (default \f[CR]F\f[R]),
2039 \f[CR]find\-next\f[R] (default \f[CR];\f[R]), \f[CR]find\-prev\f[R]
2040 (default \f[CR],\f[R]).
2041 You can disable \f[CR]anchorfind\f[R] option to match a pattern at an
2042 arbitrary position in the filename instead of the beginning.
2043 You can set the number of keys to match using \f[CR]findlen\f[R] option.
2044 If you set this value to zero, then the keys are read until there is
2045 only a single match.
2046 The default values of these two options are set to jump to the first
2047 file with the given initial.
2048 .PP
2049 Some options affect both searching and finding.
2050 You can disable \f[CR]wrapscan\f[R] option to prevent searches from
2051 being wrapped around at the end of the file list.
2052 You can disable \f[CR]ignorecase\f[R] option to match cases in the
2053 pattern and the filename.
2054 This option is already automatically overridden if the pattern contains
2055 uppercase characters.
2056 You can disable \f[CR]smartcase\f[R] option to disable this behavior.
2057 Two similar options \f[CR]ignoredia\f[R] and \f[CR]smartdia\f[R] are
2058 provided to control matching diacritics in Latin letters.
2059 .SH OPENING FILES
2060 You can define an \f[CR]open\f[R] command (default \f[CR]l\f[R] and
2061 \f[CR]<right>\f[R]) to configure file opening.
2062 This command is only called when the current file is not a directory,
2063 otherwise, the directory is entered instead.
2064 You can define it just as you would define any other command:
2065 .IP
2066 .EX
2067 cmd open $vi $fx
2068 .EE
2069 .PP
2070 It is possible to use different command types:
2071 .IP
2072 .EX
2073 cmd open &xdg\-open $f
2074 .EE
2075 .PP
2076 You may want to use either file extensions or MIME types from
2077 \f[CR]file\f[R] command:
2078 .IP
2079 .EX
2080 cmd open ${{
2081 case $(file \-\-mime\-type \-Lb $f) in
2082 text/*) vi $fx;;
2083 *) for f in $fx; do xdg\-open $f > /dev/null 2> /dev/null & done;;
2084 esac
2085 }}
2086 .EE
2087 .PP
2088 You may want to use \f[CR]setsid\f[R] before your opener command to have
2089 persistent processes that continue to run after lf quits.
2090 .PP
2091 Regular shell commands (i.e.
2092 \f[CR]$\f[R]) drop to the terminal which results in a flicker for
2093 commands that finish immediately (e.g.
2094 \f[CR]xdg\-open\f[R] in the above example).
2095 If you want to use asynchronous shell commands (i.e.
2096 \f[CR]&\f[R]) but also want to use the terminal when necessary (e.g.
2097 \f[CR]vi\f[R] in the above example), you can use a remote command:
2098 .IP
2099 .EX
2100 cmd open &{{
2101 case $(file \-\-mime\-type \-Lb $f) in
2102 text/*) lf \-remote \(dqsend $id \(rs$vi \(rs$fx\(dq;;
2103 *) for f in $fx; do xdg\-open $f > /dev/null 2> /dev/null & done;;
2104 esac
2105 }}
2106 .EE
2107 .PP
2108 Note that asynchronous shell commands run in their own process group by
2109 default so they do not require the manual use of \f[CR]setsid\f[R].
2110 .PP
2111 The following command is provided by default:
2112 .IP
2113 .EX
2114 cmd open &$OPENER $f
2115 .EE
2116 .PP
2117 You may also use any other existing file openers as you like.
2118 Possible options are \f[CR]libfile\-mimeinfo\-perl\f[R] (executable name
2119 is \f[CR]mimeopen\f[R]), \f[CR]rifle\f[R] (ranger\(aqs default file
2120 opener), or \f[CR]mimeo\f[R] to name a few.
2121 .SH PREVIEWING FILES
2122 lf previews files on the preview pane by printing the file until the end
2123 or until the preview pane is filled.
2124 This output can be enhanced by providing a custom preview script for
2125 filtering.
2126 This can be used to highlight source code, list contents of archive
2127 files or view PDF or image files to name a few.
2128 For coloring lf recognizes ANSI escape codes.
2129 .PP
2130 To use this feature, you need to set the value of \f[CR]previewer\f[R]
2131 option to the path of an executable file.
2132 The following arguments are passed to the file, (1) current filename,
2133 (2) width, (3) height, (4) horizontal position, (5) vertical position,
2134 and (6) mode (\(dqpreview\(dq or \(dqpreload\(dq).
2135 The output of the execution is printed in the preview pane.
2136 .PP
2137 Different types of files can be handled by matching by extension (or
2138 MIME type from the \f[CR]file\f[R] command):
2139 .IP
2140 .EX
2141 #!/bin/sh
2142
2143 case \(dq$1\(dq in
2144 *.tar*) tar tf \(dq$1\(dq;;
2145 *.zip) unzip \-l \(dq$1\(dq;;
2146 *.rar) unrar l \(dq$1\(dq;;
2147 *.7z) 7z l \(dq$1\(dq;;
2148 *.pdf) pdftotext \(dq$1\(dq \-;;
2149 *) highlight \-O ansi \(dq$1\(dq;;
2150 esac
2151 .EE
2152 .PP
2153 Because files can be large, lf automatically closes the previewer script
2154 output pipe with a SIGPIPE when enough lines are read.
2155 Note that some programs may not respond well to SIGPIPE and will exit
2156 with a non\-zero return code, which avoids caching.
2157 You may add a trailing \f[CR]|| true\f[R] command to avoid such errors:
2158 .IP
2159 .EX
2160 highlight \-O ansi \(dq$1\(dq || true
2161 .EE
2162 .PP
2163 You may also want to use the same script in your pager mapping as well:
2164 .IP
2165 .EX
2166 set previewer \(ti/.config/lf/pv.sh
2167 map i $\(ti/.config/lf/pv.sh $f | less \-R
2168 .EE
2169 .PP
2170 For \f[CR]less\f[R] pager, you may instead utilize \f[CR]LESSOPEN\f[R]
2171 mechanism so that useful information about the file such as the full
2172 path of the file can still be displayed in the statusline below:
2173 .IP
2174 .EX
2175 set previewer \(ti/.config/lf/pv.sh
2176 map i $LESSOPEN=\(aq| \(ti/.config/lf/pv.sh %s\(aq less \-R $f
2177 .EE
2178 .PP
2179 Since the preview script is called for each file selection change, it
2180 may not generate previews fast enough if the user scrolls through files
2181 quickly.
2182 To deal with this, the \f[CR]preload\f[R] option can be set to enable
2183 file previews to be preloaded in advance.
2184 If enabled, the preview script will be run on files in advance as the
2185 user navigates through them.
2186 In this case, if the exit code of the preview script is zero, then the
2187 output will be cached in memory and displayed by lf (useful for text or
2188 sixel previews).
2189 Otherwise, it will fall back to calling the preview script again when
2190 the file is actually selected (useful for previews managed by an
2191 external program).
2192 .SH CHANGING DIRECTORY
2193 lf changes the working directory of the process to the current directory
2194 so that shell commands always work in the displayed directory.
2195 After quitting, it returns to the original directory where it is first
2196 launched like all shell programs.
2197 If you want to stay in the current directory after quitting, you can use
2198 one of the example lfcd wrapper shell scripts provided in the repository
2199 at \c
2200 .UR https://github.com/gokcehan/lf/tree/master/etc
2201 .UE \c
2202 .PP
2203 There is a special command \f[CR]on\-cd\f[R] that runs a shell command
2204 when it is defined and the directory is changed.
2205 You can define it just as you would define any other command:
2206 .IP
2207 .EX
2208 cmd on\-cd &{{
2209 bash \-c \(aq
2210 # display git repository status in your prompt
2211 source /usr/share/git/completion/git\-prompt.sh
2212 GIT_PS1_SHOWDIRTYSTATE=auto
2213 GIT_PS1_SHOWSTASHSTATE=auto
2214 GIT_PS1_SHOWUNTRACKEDFILES=auto
2215 GIT_PS1_SHOWUPSTREAM=auto
2216 git=$(__git_ps1 \(dq (%s)\(dq)
2217 fmt=\(dq\(rs033[32;1m%u\(at%h\(rs033[0m:\(rs033[34;1m%d\(rs033[0m\(rs033[1m%f$git\(rs033[0m\(dq
2218 lf \-remote \(dqsend $id set promptfmt \(rs\(dq$fmt\(rs\(dq\(dq
2219 \(aq
2220 }}
2221 .EE
2222 .PP
2223 If you want to send escape sequences to the terminal, you can use the
2224 \f[CR]tty\-write\f[R] command to do so.
2225 The following xterm\-specific escape sequence sets the terminal title to
2226 the working directory:
2227 .IP
2228 .EX
2229 cmd on\-cd &{{
2230 lf \-remote \(dqsend $id tty\-write \(rs\(dq\(rs033]0;$PWD\(rs007\(rs\(dq\(dq
2231 }}
2232 .EE
2233 .PP
2234 This command runs whenever you change the directory but not on startup.
2235 You can add an extra call to make it run on startup as well:
2236 .IP
2237 .EX
2238 cmd on\-cd &{{ ... }}
2239 on\-cd
2240 .EE
2241 .PP
2242 Note that all shell command types can be used, but \f[CR]%\f[R] and
2243 \f[CR]&\f[R] are usually more appropriate, as \f[CR]$\f[R] and
2244 \f[CR]!\f[R] cause flickering and pauses respectively.
2245 .PP
2246 There is also a \f[CR]pre\-cd\f[R] command, that works like
2247 \f[CR]on\-cd\f[R], but is run before the directory is actually changed.
2248 Another related command is \f[CR]on\-load\f[R] which gets executed when
2249 loading a directory.
2250 .SH LOADING DIRECTORY
2251 Similar to \f[CR]on\-cd\f[R] there also is \f[CR]on\-load\f[R] that when
2252 defined runs a shell command after loading a directory.
2253 It works well when combined with \f[CR]addcustominfo\f[R].
2254 .PP
2255 The following example can be used to display git indicators in the info
2256 column:
2257 .IP
2258 .EX
2259 cmd on\-load &{{
2260 cd \(dq$(dirname \(dq$1\(dq)\(dq || exit 1
2261 [ \(dq$(git rev\-parse \-\-is\-inside\-git\-dir 2>/dev/null)\(dq = false ] || exit 0
2262
2263 cmds=\(dq\(dq
2264
2265 for file in \(dq$\(at\(dq; do
2266 case \(dq$file\(dq in
2267 */.git|*/.git/*) continue;;
2268 esac
2269
2270 status=$(git status \-\-porcelain \-\-ignored \-\- \(dq$file\(dq | cut \-c1\-2 | head \-n1)
2271
2272 if [ \-n \(dq$status\(dq ]; then
2273 cmds=\(dq${cmds}addcustominfo \(rs\(dq${file}\(rs\(dq \(rs\(dq$status\(rs\(dq; \(dq
2274 else
2275 cmds=\(dq${cmds}addcustominfo \(rs\(dq${file}\(rs\(dq \(aq\(aq; \(dq
2276 fi
2277 done
2278
2279 if [ \-n \(dq$cmds\(dq ]; then
2280 lf \-remote \(dqsend $id :$cmds\(dq
2281 fi
2282 }}
2283 .EE
2284 .PP
2285 Another use case could be showing the dimensions of images and videos:
2286 .IP
2287 .EX
2288 cmd on\-load &{{
2289 cmds=\(dq\(dq
2290
2291 for file in \(dq$\(at\(dq; do
2292 mime=$(file \-\-mime\-type \-Lb \-\- \(dq$file\(dq)
2293 case \(dq$mime\(dq in
2294 # vector images cause problems
2295 image/svg+xml)
2296 ;;
2297 image/*|video/*)
2298 dimensions=$(exiftool \-s3 \-imagesize \-\- \(dq$file\(dq)
2299 cmds=\(dq${cmds}addcustominfo \(rs\(dq${file}\(rs\(dq \(rs\(dq$dimensions\(rs\(dq; \(dq
2300 ;;
2301 esac
2302 done
2303
2304 if [ \-n \(dq$cmds\(dq ]; then
2305 lf \-remote \(dqsend $id :$cmds\(dq
2306 fi
2307 }}
2308 .EE
2309 .SH COLORS
2310 lf tries to automatically adapt its colors to the environment.
2311 It starts with a default color scheme and updates colors using values of
2312 existing environment variables possibly by overwriting its previous
2313 values.
2314 Colors are set in the following order:
2315 .IP "1." 3
2316 default
2317 .IP "2." 3
2318 LSCOLORS (macOS/BSD ls)
2319 .IP "3." 3
2320 LS_COLORS (GNU ls)
2321 .IP "4." 3
2322 LF_COLORS (lf specific)
2323 .IP "5." 3
2324 colors file (lf specific)
2325 .PP
2326 Please refer to the corresponding man pages for more information about
2327 \f[CR]LSCOLORS\f[R] and \f[CR]LS_COLORS\f[R].
2328 \f[CR]LF_COLORS\f[R] is provided with the same syntax as
2329 \f[CR]LS_COLORS\f[R] in case you want to configure colors only for lf
2330 but not ls.
2331 This can be useful since there are some differences between ls and lf,
2332 though one should expect the same behavior for common cases.
2333 The colors file (refer to the \c
2334 .UR https://github.com/gokcehan/lf/blob/master/doc.md#configuration
2335 CONFIGURATION section
2336 .UE \c
2337 ) is provided for easier configuration without environment variables.
2338 This file should consist of whitespace\-separated pairs with a
2339 \f[CR]#\f[R] character to start comments until the end of the line.
2340 .PP
2341 You can configure lf colors in two different ways.
2342 First, you can only configure 8 basic colors used by your terminal and
2343 lf should pick up those colors automatically.
2344 Depending on your terminal, you should be able to select your colors
2345 from a 24\-bit palette.
2346 This is the recommended approach as colors used by other programs will
2347 also match each other.
2348 .PP
2349 Second, you can set the values of environment variables or colors file
2350 mentioned above for fine\-grained customization.
2351 Note that \f[CR]LS_COLORS/LF_COLORS\f[R] are more powerful than
2352 \f[CR]LSCOLORS\f[R] and they can be used even when GNU programs are not
2353 installed on the system.
2354 You can combine this second method with the first method for the best
2355 results.
2356 .PP
2357 Lastly, you may also want to configure the colors of the prompt line to
2358 match the rest of the colors.
2359 Colors of the prompt line can be configured using the
2360 \f[CR]promptfmt\f[R] option which can include hardcoded colors as ANSI
2361 escapes.
2362 See the default value of this option to have an idea about how to color
2363 this line.
2364 .PP
2365 It is worth noting that lf uses as many colors as advertised by your
2366 terminal\(aqs entry in terminfo or infocmp databases on your system.
2367 If an entry is not present, it falls back to an internal database.
2368 If your terminal supports 24\-bit colors but either does not have a
2369 database entry or does not advertise all capabilities, you can enable
2370 support by setting the \f[CR]$COLORTERM\f[R] variable to
2371 \f[CR]truecolor\f[R] or ensuring \f[CR]$TERM\f[R] is set to a value that
2372 ends with \f[CR]\-truecolor\f[R].
2373 .PP
2374 Default lf colors are mostly taken from GNU dircolors defaults.
2375 These defaults use 8 basic colors and bold attribute.
2376 Default dircolors entries with background colors are simplified to avoid
2377 confusion with current file selection in lf.
2378 Similarly, there are only file type matchings and extension matchings
2379 are left out for simplicity.
2380 Default values are as follows given with their matching order in lf:
2381 .IP
2382 .EX
2383 ln 01;36
2384 or 31;01
2385 tw 01;34
2386 ow 01;34
2387 st 01;34
2388 di 01;34
2389 pi 33
2390 so 01;35
2391 bd 33;01
2392 cd 33;01
2393 su 01;32
2394 sg 01;32
2395 ex 01;32
2396 fi 00
2397 .EE
2398 .PP
2399 Note that lf first tries matching file names and then falls back to file
2400 types.
2401 The full order of matchings from most specific to least are as follows:
2402 .IP "1." 3
2403 Full Path (e.g.
2404 \f[CR]\(ti/.config/lf/lfrc\f[R])
2405 .IP "2." 3
2406 Dir Name (e.g.
2407 \f[CR].git/\f[R]) (only matches dirs with a trailing slash at the end)
2408 .IP "3." 3
2409 File Type (e.g.
2410 \f[CR]ln\f[R]) (except \f[CR]fi\f[R])
2411 .IP "4." 3
2412 File Name (e.g.
2413 \f[CR]README*\f[R])
2414 .IP "5." 3
2415 File Name (e.g.
2416 \f[CR]*README\f[R])
2417 .IP "6." 3
2418 Base Name (e.g.
2419 \f[CR]README.*\f[R])
2420 .IP "7." 3
2421 Extension (e.g.
2422 \f[CR]*.txt\f[R])
2423 .IP "8." 3
2424 Default (i.e.
2425 \f[CR]fi\f[R])
2426 .PP
2427 For example, given a regular text file \f[CR]/path/to/README.txt\f[R],
2428 the following entries are checked in the configuration and the first one
2429 to match is used:
2430 .IP "1." 3
2431 \f[CR]/path/to/README.txt\f[R]
2432 .IP "2." 3
2433 (skipped since the file is not a directory)
2434 .IP "3." 3
2435 (skipped since the file is of type \f[CR]fi\f[R])
2436 .IP "4." 3
2437 \f[CR]README.txt*\f[R]
2438 .IP "5." 3
2439 \f[CR]*README.txt\f[R]
2440 .IP "6." 3
2441 \f[CR]README.*\f[R]
2442 .IP "7." 3
2443 \f[CR]*.txt\f[R]
2444 .IP "8." 3
2445 \f[CR]fi\f[R]
2446 .PP
2447 Given a regular directory \f[CR]/path/to/example.d\f[R], the following
2448 entries are checked in the configuration and the first one to match is
2449 used:
2450 .IP "1." 3
2451 \f[CR]/path/to/example.d\f[R]
2452 .IP "2." 3
2453 \f[CR]example.d/\f[R]
2454 .IP "3." 3
2455 \f[CR]di\f[R]
2456 .IP "4." 3
2457 \f[CR]example.d*\f[R]
2458 .IP "5." 3
2459 \f[CR]*example.d\f[R]
2460 .IP "6." 3
2461 \f[CR]example.*\f[R]
2462 .IP "7." 3
2463 \f[CR]*.d\f[R]
2464 .IP "8." 3
2465 \f[CR]fi\f[R]
2466 .PP
2467 Note that glob\-like patterns do not perform glob matching for
2468 performance reasons.
2469 .PP
2470 For example, you can set a variable as follows:
2471 .IP
2472 .EX
2473 export LF_COLORS=\(dq\(ti/Documents=01;31:\(ti/Downloads=01;31:\(ti/.local/share=01;31:\(ti/.config/lf/lfrc=31:.git/=01;32:.git*=32:*.gitignore=32:*Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:\(dq
2474 .EE
2475 .PP
2476 Having all entries on a single line can make it hard to read.
2477 You may instead divide it into multiple lines in between double quotes
2478 by escaping newlines with backslashes as follows:
2479 .IP
2480 .EX
2481 export LF_COLORS=\(dq\(rs
2482 \(ti/Documents=01;31:\(rs
2483 \(ti/Downloads=01;31:\(rs
2484 \(ti/.local/share=01;31:\(rs
2485 \(ti/.config/lf/lfrc=31:\(rs
2486 \&.git/=01;32:\(rs
2487 \&.git*=32:\(rs
2488 *.gitignore=32:\(rs
2489 *Makefile=32:\(rs
2490 README.*=33:\(rs
2491 *.txt=34:\(rs
2492 *.md=34:\(rs
2493 ln=01;36:\(rs
2494 di=01;34:\(rs
2495 ex=01;32:\(rs
2496 \(dq
2497 .EE
2498 .PP
2499 The \f[CR]ln\f[R] entry supports the special value \f[CR]target\f[R],
2500 which will use the link target to select a style.
2501 Filename rules will still apply based on the link\(aqs name \-\- this
2502 mirrors GNU\(aqs \f[CR]ls\f[R] and \f[CR]dircolors\f[R] behavior.
2503 Having such a long variable definition in a shell configuration file
2504 might be undesirable.
2505 You may instead use the colors file (refer to the \c
2506 .UR https://github.com/gokcehan/lf/blob/master/doc.md#configuration
2507 CONFIGURATION section
2508 .UE \c
2509 ) for configuration.
2510 A sample colors file can be found at \c
2511 .UR https://github.com/gokcehan/lf/blob/master/etc/colors.example
2512 .UE \c
2513 \ You may also see the wiki page for ANSI escape codes \c
2514 .UR https://en.wikipedia.org/wiki/ANSI_escape_code
2515 .UE \c
2516 .SH ICONS
2517 Icons are configured using \f[CR]LF_ICONS\f[R] environment variable or
2518 an icons file (refer to the \c
2519 .UR https://github.com/gokcehan/lf/blob/master/doc.md#configuration
2520 CONFIGURATION section
2521 .UE \c
2522 ).
2523 The variable uses the same syntax as \f[CR]LS_COLORS/LF_COLORS\f[R].
2524 Instead of colors, you should use single characters or symbols as
2525 values.
2526 The \f[CR]ln\f[R] entry supports the special value \f[CR]target\f[R],
2527 which will use the link target to select an icon.
2528 Filename rules will still apply based on the link\(aqs name \-\- this
2529 mirrors GNU\(aqs \f[CR]ls\f[R] and \f[CR]dircolors\f[R] behavior.
2530 The icons file (refer to the \c
2531 .UR https://github.com/gokcehan/lf/blob/master/doc.md#configuration
2532 CONFIGURATION section
2533 .UE \c
2534 ) should consist of whitespace\-separated arrays with a \f[CR]#\f[R]
2535 character to start comments until the end of the line.
2536 Each line should contain 1\-3 columns: a file type or file name pattern,
2537 the icon, and an optional icon color.
2538 Using only one column disables all rules for that type or name.
2539 Do not forget to add \f[CR]set icons true\f[R] to your \f[CR]lfrc\f[R]
2540 to see the icons.
2541 Default values are listed below in the order lf matches them:
2542 .IP
2543 .EX
2544 ln l
2545 or l
2546 tw t
2547 ow d
2548 st t
2549 di d
2550 pi p
2551 so s
2552 bd b
2553 cd c
2554 su u
2555 sg g
2556 ex x
2557 fi \-
2558 .EE
2559 .PP
2560 A sample icons file can be found at \c
2561 .UR https://github.com/gokcehan/lf/blob/master/etc/icons.example
2562 .UE \c
2563 .PP
2564 A sample colored icons file can be found at \c
2565 .UR https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example
2566 .UE \c
2567 .SH RULER
2568 The ruler can be configured using the \f[CR]rulerfile\f[R] option (refer
2569 to the \c
2570 .UR https://github.com/gokcehan/lf/blob/master/doc.md#configuration
2571 CONFIGURATION section
2572 .UE \c
2573 ).
2574 The contents of the ruler file should be a Go template which is then
2575 rendered to create the actual output (refer to \c
2576 .UR https://pkg.go.dev/text/template
2577 .UE \c
2578 \ for more details on the syntax).
2579 .PP
2580 The following data fields are exported:
2581 .IP
2582 .EX
2583 \&.Message string Includes internal messages, errors, and messages generated by the \(gaecho\(ga/\(gaechomsg\(ga/\(gaechoerr\(ga commands
2584 \&.Keys string Keys pressed by the user
2585 \&.Progress []string Progress indicators for copied, moved and deleted files
2586 \&.Copy []string List of files in the clipboard to be copied
2587 \&.Cut []string List of files in the clipboard to be moved
2588 \&.Select []string Selection list
2589 \&.Visual []string Visual selection
2590 \&.Index int Index of the cursor
2591 \&.Total int Number of visible files in the current working directory
2592 \&.Hidden int Number of hidden files in the current working directory
2593 \&.All int Number of all files in the current working directory
2594 \&.LinePercentage string Line percentage (analogous to \(ga%p\(ga for the \(gastatusline\(ga option in Vim)
2595 \&.ScrollPercentage string Scroll percentage (analogous to \(ga%P\(ga for the \(gastatusline\(ga option in Vim)
2596 \&.Filter []string Filter currently being applied
2597 \&.Mode string Current mode (\(dqNORMAL\(dq for Normal mode, and \(dqVISUAL\(dq for Visual mode)
2598 \&.Options map[string]string The value of options (e.g. \(ga{{.Options.hidden}}\(ga)
2599 \&.UserOptions map[string]string The value of user\-defined options (e.g. \(ga{{.UserOptions.foo}}\(ga)
2600 \&.Stat.Path string Path of the current file
2601 \&.Stat.Name string Name of the current file
2602 \&.Stat.Extension string Extension of the current file
2603 \&.Stat.Size int64 Size of the current file
2604 \&.Stat.DirSize int64 Total size of the current directory if calculated via \(gacalcdirsize\(ga (\(ga\-1\(ga if not calculated)
2605 \&.Stat.DirCount int Number of items in the current directory if the \(gadircounts\(ga option is enabled (\(ga\-1\(ga if the directory cannot be read)
2606 \&.Stat.Permissions string Permissions of the current file
2607 \&.Stat.ModTime string Last modified time of the current file (formatted based on the \(gatimefmt\(ga option)
2608 \&.Stat.AccessTime string Last access time of the current file (formatted based on the \(gatimefmt\(ga option)
2609 \&.Stat.BirthTime string Birth time of the current file (formatted based on the \(gatimefmt\(ga option)
2610 \&.Stat.ChangeTime string Last status (inode) change time of the current file (formatted based on the \(gatimefmt\(ga option)
2611 \&.Stat.LinkCount string Number of hard links for the current file
2612 \&.Stat.User string User of the current file
2613 \&.Stat.Group string Group of the current file
2614 \&.Stat.Target string Target if the current file is a symbolic link, otherwise a blank string
2615 \&.Stat.CustomInfo string Custom property if defined via \(gaaddcustominfo\(ga, otherwise a blank string
2616 .EE
2617 .PP
2618 The following functions are exported:
2619 .IP
2620 .EX
2621 df func() string Get an indicator representing the amount of free disk space available
2622 env func(string) string Get the value of an environment variable
2623 humanize func(int64) string Express a file size in a human\-readable format
2624 join func([]string, string) string Join a string array by a separator
2625 lower func(string) string Convert a string to lowercase
2626 substr func(string, int, int) string Get a substring based on starting index and length
2627 upper func(string) string Convert a string to uppercase
2628 .EE
2629 .PP
2630 The special identifier \f[CR]{{.SPACER}}\f[R] can be used to divide the
2631 ruler into sections that are spaced evenly from each other.
2632 .PP
2633 The default ruler file can be found at \c
2634 .UR https://github.com/gokcehan/lf/blob/master/etc/ruler.default
2635 .UE \c