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