Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5c2cc44d8 | ||
|
|
bfea67dec6 | ||
|
|
f40c626c4d | ||
|
|
c2049e05c2 | ||
|
|
7fd12a2a70 | ||
|
|
397f75e4a5 | ||
|
|
cb8026d627 | ||
|
|
bf314a32f4 | ||
|
|
404050af30 | ||
|
|
e47b2fda08 | ||
|
|
0639e71171 | ||
|
|
e47600e428 | ||
|
|
017951fd6b | ||
|
|
35b2764e27 | ||
|
|
44e716d2f1 | ||
|
|
c3b184fc2e | ||
|
|
8c5648ab33 | ||
|
|
17971fd66e | ||
|
|
ff0c7f1c96 | ||
|
|
b76d2546e1 | ||
|
|
249264b4cd | ||
|
|
320322c5cd | ||
|
|
0da0d79ede | ||
|
|
399b98da93 | ||
|
|
fe3a97c5d0 | ||
|
|
7507be4d04 | ||
|
|
2494b3f632 | ||
|
|
b25976cef7 | ||
|
|
4666a0b875 | ||
|
|
7158e09033 | ||
|
|
e7ea6c6d0d | ||
|
|
fea705ef7f | ||
|
|
12f235fac9 | ||
|
|
62cbe0b6b5 | ||
|
|
84c57cc58a | ||
|
|
11b0d4e238 | ||
|
|
f175d7ed30 | ||
|
|
ce13438ab4 | ||
|
|
6616c9c119 | ||
|
|
40770d7dee | ||
|
|
7a89808688 |
No files matched your search
@@ -29,7 +29,7 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
run: go test -v ./...
|
run: go test -v ./...
|
||||||
|
|
||||||
- uses: dominikh/staticcheck-action@v1.3.1
|
- uses: dominikh/staticcheck-action@v1.4.0
|
||||||
with:
|
with:
|
||||||
version: "2024.1.1"
|
version: "2024.1.1"
|
||||||
install-go: false
|
install-go: false
|
||||||
|
|||||||
+834
@@ -0,0 +1,834 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
All changes observable to end users should be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and should contain the following sections for each release:
|
||||||
|
|
||||||
|
- `Changed`
|
||||||
|
- `Added`
|
||||||
|
- `Fixed`
|
||||||
|
|
||||||
|
## [r36](https://github.com/gokcehan/lf/releases/tag/r36)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Tagging symbolic links now affects the target instead of the symbolic link itself. This mimics the behavior in `ranger` (#1997).
|
||||||
|
- The experimental command `invert-below` has been removed in favor of the newly added support for Visual mode (#2021).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new placeholder `%P` representing the scroll percentage is added to the `rulerfmt` option (#1985).
|
||||||
|
- A new `on-load` hook command is added, which is triggered when files in a directory are loaded in `lf` (#2010).
|
||||||
|
- The `info` option now supports `custom`, allowing users to display custom information for each file (#2012). The custom information should be added by the user via the `addcustominfo` command. Sorting by the custom information is also supported (#2019).
|
||||||
|
- Support for `visual-mode` has now been added (#2021) (#2035). This includes the following changes:
|
||||||
|
- A new command `visual` (default `V`) can be used to enter Visual mode.
|
||||||
|
- A new command `visual-change` (default `o` in Visual mode) can be used to swap the positions of the cursor and anchor (start of the visual selection).
|
||||||
|
- A new command `visual-accept` (default `V` in Visual mode) can be used to exit Visual mode, adding the visual selection to the selection list.
|
||||||
|
- A new command `visual-discard` (default `<esc>` in Visual mode) can be used to exit Visual mode, without adding the visual selection to the selection list.
|
||||||
|
- A new command `visual-unselect` can be used to exit Visual mode, removing the visual selection from the selection list.
|
||||||
|
- The existing `map` command now adds keybindings for both Normal and Visual modes. Two new commands `nmap` and `vmap` are added which can be used to add keybindings for only Normal or Visual mode respectively.
|
||||||
|
- Two new commands `nmaps` and `vmaps` are added to display the list of keybindings in Normal and Visual mode respectively. These, along with the existing `maps` and `cmaps` commands, now display an extra column indicating the mode for which the keybindings apply to.
|
||||||
|
- A new option `visualfmt` is added to customize the appearance of the visual selection.
|
||||||
|
- Two new placeholders `%m` and `%M` are added to `statfmt` to display the mode in the status line. Both will display `VISUAL` when in Visual mode, however in Normal mode `%m` will display as a blank string while `%M` will display `NORMAL`.
|
||||||
|
- A new placeholder `%v` is added to `rulerfmt` which displays the number of files in the Visual selection. This is included in the default setting for `rulerfmt`.
|
||||||
|
- The `lf_mode` environment variable will now be set to `visual` while in Visual mode.
|
||||||
|
- The environment variable `$fv` is now exported to shell commands, which lists the files in the visual selection.
|
||||||
|
- A `CHANGELOG.md` file has been added to the repo (#2027). This will be updated to describe `Changed`, `Added` and `Fixed` functionality for each new release.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Displaying sixel images now uses the screen locking API in Tcell, which reduces flickering in the UI (#1943).
|
||||||
|
- The `cmd-history` command is now ignored outside of Normal or Command-line mode, to prevent accidentally escaping out of other modes (#1971).
|
||||||
|
- A potential crash when using the `cmd-delete-word-back` command is fixed (#1976).
|
||||||
|
- The `preserve` option now applies to directories in addition to files when copying. This includes preserving `timestamps` (#1979) and `mode` (#1981).
|
||||||
|
- The `lfrc.ps1.example` example config file is updated to include PowerShell equivalents for the default commands and keybindings (#1989).
|
||||||
|
- Quoting for the `lf` environment variable is fixed for PowerShell users (#1990).
|
||||||
|
- `tempmarks` are no longer cleared after the `sync` command is called (#1996).
|
||||||
|
- The file stat information is no longer displayed during the execution of a `shell-pipe` command even if the file is updated (#2002).
|
||||||
|
- Directories are now reloaded properly if any component in the current path is renamed (#2005).
|
||||||
|
- Write updates for the log file are now ignored when `watch` is enabled. This helps to reduce notification spam and potential of infinite loops (#2015).
|
||||||
|
- Attempting to `cut`/`copy` files into a directory without execute permissions no longer causes `lf` to crash, and an error message will be displayed instead (#2024).
|
||||||
|
|
||||||
|
## [r35](https://github.com/gokcehan/lf/releases/tag/r35)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support is added for displaying underline styles (#1896).
|
||||||
|
- Support is added for displaying underline colors (#1933).
|
||||||
|
- A new subcommand `files` is added to the `query` server command to list the files in the current directory as displayed in `lf` (#1949).
|
||||||
|
- A new `tty-write` command is added for sending escape sequences to the terminal (#1961). **Writing directly to `/dev/tty` is not recommended as it not synchronized and can interfere with drawing the UI.**
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The `trash` command in `lfrc.example` now verifies if the trash directory exists before moving files there (#1918).
|
||||||
|
- `lf` should no longer crash if it fails to open the log file (#1937).
|
||||||
|
- Arrow keys are now handled properly when waiting for a key press after executing a `shell-wait` (`!`) command (#1956).
|
||||||
|
- The `previewer` script is now only invoked for the current directory (instead of all directories), when starting `lf` with `dirpreviews` enabled (#1958).
|
||||||
|
|
||||||
|
## [r34](https://github.com/gokcehan/lf/releases/tag/r34)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The `autoquit` option is now enabled by default (#1839).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new option `locale` is added to sort files based on the collation rules of the provided locale (#1818). **This feature is currently experimental.**
|
||||||
|
- A new `on-init` hook command is added to allow triggering custom actions when `lf` has finished initializing and connecting to the server (#1838).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The background color now renders properly when displaying filenames (#1849).
|
||||||
|
- A bug where the `on-quit` hook command causes an infinite loop has been fixed (#1856).
|
||||||
|
- File sizes now display correctly after being copied when `watch` is enabled (#1881).
|
||||||
|
- Files are now automatically unselected when removed by an external process, when `watch` is enabled (#1901).
|
||||||
|
|
||||||
|
## [r33](https://github.com/gokcehan/lf/releases/tag/r33)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The `globsearch` option, which previously affected both searching and filtering, now affects only searching. A new `globfilter` option is introduced to enable globs when filtering, and acts independently from `globsearch` (#1650).
|
||||||
|
- The `hidecursorinactive` option is replaced by the `on-focus-gained` and `on-focus-lost` hook commands. These commands can be used to invoke custom behavior when the terminal gains or loses focus (#1763).
|
||||||
|
- The `ruler` option (deprecated in favor of `rulerfmt`) is now removed (#1766).
|
||||||
|
- Line numbers from the `number` and `relativenumber` options are displayed in the main window only, instead of all windows (#1789).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for Unix domain sockets (for communicating with the `lf` server) is added for Windows (#1637).
|
||||||
|
- Color and icon configurations now support the `target` keyword for symbolic links (#1644).
|
||||||
|
- A new option `roundbox` is added to use rounded corners when `drawbox` is enabled (#1653).
|
||||||
|
- A new option `watch` is added to allow using filesystem notifications to detect and display changes to files. This is an alternative to the `period` option, which polls the filesystem periodically for changes (#1667).
|
||||||
|
- Icons can now be colored independently of the filename (#1674).
|
||||||
|
- The `info` option now supports `perm`, `user` and `group` to display the permissions, user and group respectively for each file (#1799).
|
||||||
|
- A new option `showbinds` is added to toggle whether the keybinding hints are shown when a keybinding is partially typed (#1815).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Sorting by extension is fixed for hidden files (#1670).
|
||||||
|
- The `on-quit` hook command is now triggered when the terminal is closed (#1681).
|
||||||
|
- Previews no longer flicker when deleting files (#1691).
|
||||||
|
- Previews no longer flicker when directories are being reloaded (#1697).
|
||||||
|
- `lfcd.nu` now runs properly without raising errors (#1728).
|
||||||
|
- Image previews (composed of ASCII art) containing long lines should now display properly (#1737).
|
||||||
|
- The performance is improved when copying files (#1749).
|
||||||
|
- `lfcd.cmd` now handles directories with special characters (#1772).
|
||||||
|
- Icon colors are no longer clipped when displaying in Windows Terminal (#1777).
|
||||||
|
- The file stat info is now cleared when changing to an empty directory (#1808).
|
||||||
|
- Error messages are cleared when opening files (#1809).
|
||||||
|
|
||||||
|
## [r32](https://github.com/gokcehan/lf/releases/tag/r32)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The example script `etc/lfcd.cmd` is updated to use the `-print-last-dir` option instead of `-last-dir-path` (#1444). Similar changes have been made for `etc/lfcd.ps1` (#1491), `etc/lfcd.fish` (#1503), and `etc/lfcd.nu` (#1575).
|
||||||
|
- The documentation from `lf -doc` and the `doc` command is now generated from Markdown using `pandoc` (#1474).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new option `hidecursorinactive` is added to hide the cursor when the terminal is not focused (#965).
|
||||||
|
- A new special command `on-redraw` is added to be able to run a command when the screen is redrawn or when the terminal is resized (#1479).
|
||||||
|
- Options `cutfmt`, `copyfmt` and `selectfmt` are added to configure the indicator color for cut/copied/selected files respectively (#1540).
|
||||||
|
- `zsh` completion is added for the `lfcd` command (#1564).
|
||||||
|
- The file stat information now falls back to displaying user/group ID if looking up the user/group name fails (#1590).
|
||||||
|
- A new environment variable `lf_mode` is now exported to indicate which mode `lf` is currently running in (#1594).
|
||||||
|
- Default icons are added for Docker Compose files (#1626).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Default value of `rulerfmt` option is now left-padded with spaces to visually separate it from the file stat information (#1437).
|
||||||
|
- Previews should now work for files containing lines with 65536 characters or more (#1447).
|
||||||
|
- Sixel previews should now work when using `lfcd` scripts (#1451).
|
||||||
|
- Colors and icons should now display properly for character device files (#1469).
|
||||||
|
- The selection file is now immediately synced to physical storage after writing to it (#1480).
|
||||||
|
- Timestamps are preserved when moving files across devices (#1482).
|
||||||
|
- Fix crash for `high` and `low` commands when `scrolloff` is set to a large value (#1504).
|
||||||
|
- Documentation is updated with various spelling and grammar fixes (#1518).
|
||||||
|
- Files beginning with a dot (e.g. `.gitignore`) are named correctly after `paste` if another file with the same name already exists (#1525).
|
||||||
|
- Prevent potential race condition when sorting directory contents (#1526).
|
||||||
|
- Signals are now handled properly even after receiving and ignoring `SIGINT` (#1549).
|
||||||
|
- The file stat information should now update properly after using the `cd` command to change to a directory for the first time (#1536).
|
||||||
|
- Previous error messages should now be cleared after a `mark-save`/`mark-remove` operation (#1544).
|
||||||
|
- Fix high CPU usage issue when viewing CryFS filesystems (#1607).
|
||||||
|
- Invalid entries in the `marks` and `tags` files now raise an error message instead of crashing (#1614).
|
||||||
|
- Startup time is improved on Windows (#1617).
|
||||||
|
- Sixel previews are now resized properly when the horizontal size of the preview window changes (#1629).
|
||||||
|
- The cut buffer is only cleared if the `paste` operation succeeds (#1652).
|
||||||
|
- The extension after `.` is ignored to set the cursor position when renaming a directory (#1664).
|
||||||
|
- The option `period` should not cause flickers in sixel previews anymore (#1666).
|
||||||
|
|
||||||
|
## [r31](https://github.com/gokcehan/lf/releases/tag/r31)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- There has been some changes in the server protocol. Make sure to kill the old server process when you update to avoid errors (i.e. `lf -remote 'quit!'`).
|
||||||
|
- A new server command `query` is added to expose internal state to users (#1384). A new builtin command `cmds` is added to display the commands. The old builtin command `jumps` is now removed. The builtin commands `maps` and `cmaps` now use the new server command.
|
||||||
|
- Environment variable exporting for files and options are not performed anymore while previewing and cleaning to avoid various issues with race conditions (#1354). Cleaning program should now instead receive an additional sixth argument for the next file path to be previewed to allow comparisons with the previous file path. User options (i.e. `user_{option}`) are now exported whenever they are changed (#1418).
|
||||||
|
- Command outputs are now exclusively attached to `stderr` to allow printing the last directory or selection to `stdout` (#1399) (#1402). Two new command line options `-print-last-dir` and `-print-selection` are added to print the last directory and selection to `stdout`. The example script `etc/lfcd.sh` is updated to use `-print-last-dir` instead. Other `lfcd` scripts are also likely to be updated in the future to use the new method (patches are welcome).
|
||||||
|
- The option `ruler` is now deprecated in favor of its replacement `rulerfmt` (#1386). The new `rulerfmt` option is more capable (i.e. displays option values, supports colors and attributes, and supports optional fields) and more consistent with the rest of our options. See the documentation for more information.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Modifier keys (i.e. control, shift, alt) with special keys (e.g. arrows, enter) are now supported for most combinations (#1248).
|
||||||
|
- A new option `borderfmt` is added to configure colors for pane borders (#1251).
|
||||||
|
- New `lf` specific environment variables, `LF_CONFIG_HOME` on Windows and `LF_CONFIG/DATA_HOME` on Unix, are now supported to set the configuration directory (#1253).
|
||||||
|
- Tilde (i.e. `~`) expansion is performed during completion to be able to use expanded tilde paths as command arguments (#1246).
|
||||||
|
- A new option `preserve` is added to preserve attributes (i.e. mode and timestamps) while copying (#1026).
|
||||||
|
- The file `etc/icons.example` is updated for nerd-fonts v3.0.0 (#1271).
|
||||||
|
- A new builtin command `clearmaps` is added to clear all default keybindings except for `read` (i.e. `:`) and `cmap` keybindings to be able to `:quit` (#1286).
|
||||||
|
- A new option `statfmt` is added to configure the status line at the bottom (#1288).
|
||||||
|
- A new option `truncatepct` is added to determine the location of truncation from the beginning in terms of percentage (#1029).
|
||||||
|
- A new option `dupfilefmt` is added to configure the names of duplicate files while copying (#1315).
|
||||||
|
- Shell scripts `etc/lf.nu` and `etc/lfcd.nu` are added to the repository to allow completion and directory change with Nushell (#1341).
|
||||||
|
- Sixels are now supported for previewing (#1211). A new option `sixel` is added to enable this behavior.
|
||||||
|
- A new configuration keyword `setlocal` is added to configure directory specific options (#1381).
|
||||||
|
- A new command line command `cmd-delete-word-back` (default `a-backspace` and `a-backspace2`) is added to use word boundaries when deleting a word backwards (#1409).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Cursor positions in the directory should now be preserved after file operations that changes the directory (e.g. create or delete) (#1247).
|
||||||
|
- Option `reverse` should now respect to sort stability requirements (#1261).
|
||||||
|
- Backspace should not exit `filter` mode anymore (#1269).
|
||||||
|
- Truncated double width characters should not cause misalignment for the file information (#1272).
|
||||||
|
- Piping shell commands should not refresh the preview anymore (#1281).
|
||||||
|
- Cursor position should now update properly after a terminal resize (#1290).
|
||||||
|
- Directories should now be reloaded properly after a `delete` operation (#1292).
|
||||||
|
- Executable file completion should not add entries to the log file anymore (#1307).
|
||||||
|
- Blank input lines are now allowed in piping shell commands (#1308).
|
||||||
|
- Shell commands arguments on Windows should now be quoted properly to fix various issues (#1309).
|
||||||
|
- Reloading in a symlink directory should not follow the symlink anymore (#1327).
|
||||||
|
- Command `load` should not flicker image previews anymore (#1335).
|
||||||
|
- Asynchronous shell commands should now trigger `load` automatically when they are finished (#1345).
|
||||||
|
- Changing the value of `preview` option should now clear image previews (#1350).
|
||||||
|
- Cursor position in the status line at the bottom should now consider double width characters properly (#1348).
|
||||||
|
- Filenames should only be quoted for `cmd` on Windows to avoid quoting issues for PowerShell (#1371).
|
||||||
|
- Inaccessible files should now be included in the directory list and display their `lstat` errors in the status line at the bottom (#1382).
|
||||||
|
- Command line command `cmd-delete-word` should now add the deleted text to the yank buffer (#1409).
|
||||||
|
|
||||||
|
## [r30](https://github.com/gokcehan/lf/releases/tag/r30)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new builtin command `jumps` is added to display the jump list (#1233).
|
||||||
|
- A new possible field `filter` is added to `ruler` option to display the filter indicator (#1223).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Broken mappings for `bottom` command due to recent changes are fixed (#1240).
|
||||||
|
- Selecting a file does not scroll to bottom anymore (#1222).
|
||||||
|
- Broken builds on some platforms due to recent changes are fixed (#1168).
|
||||||
|
|
||||||
|
## [r29](https://github.com/gokcehan/lf/releases/tag/r29)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Three new options `cursoractivefmt`, `cursorparentfmt` and `cursorpreviewfmt` have been added (#1086) (#1106). The default style for the preview cursor is changed to underline. You can revert back to the old style with `set cursorpreviewfmt "\033[7m"`.
|
||||||
|
- An alternative boolean option syntax `set option true/false` is added in addition to the previous syntax `set option/nooption` (#758). If you have `set option true` in your configuration, then there is no need for any changes as it was already working as expected accidentally. If you have `set option false` in your configuration, then previously it was enabling the option instead accidentally but now it is disabling the option as intended. Any other syntax including `set option on/off` are now considered errors and result in error messages. Boolean option toggling `set option!` remains unchanged with no new alternative syntax added.
|
||||||
|
- Cursor is now placed at the file extension by default in rename prompts (#1162).
|
||||||
|
- The environment variable `VISUAL` is checked before `EDITOR` for the default editor choice (#1197).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Mouse wheel events with the Control modifier have been bound to scrolling by default (#1051).
|
||||||
|
- Option values for `tagfmt` and `errorfmt` have been simplified to be able to avoid the reset sequence (#1086).
|
||||||
|
- Two default command line bindings for `<down>` and `<up>` have been added for `cmd-history-next` and `cmd-history-prev` respectively (#1112).
|
||||||
|
- A new command `invert-below` is added to invert all selections below the cursor (#1101). **This feature is currently experimental.**
|
||||||
|
- Two new commands `maps` and `cmaps` have been added to display the current list of bindings (#1146) (#1201).
|
||||||
|
- A new option `numberfmt` is added to customize line numbers (#1177).
|
||||||
|
- A new environment variable `lf_count` is now exported to use the count in shell commands (#1187).
|
||||||
|
- A new environment variable `lf` is now exported to be used as the executable path (#1176).
|
||||||
|
- An example `mkdir` binding is added to the example configuration (#1188).
|
||||||
|
- An example binding to show execution results is added to the example configuration (#1188).
|
||||||
|
- Commands `top` and `bottom` now accepts counts to move to a specific line (#1196).
|
||||||
|
- A new option `ruler` is added to customize the ruler information with a new addition for free disk space (#1168) (#1205).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Example `lfcd` files have been made safer to be able to alias the commands as `lf` (#1049).
|
||||||
|
- Backspace should not exit from `rename:` mode anymore (#1060).
|
||||||
|
- Preview is now refreshed even if the selection does not change (#1074).
|
||||||
|
- Stale directory cache entry is now deleted during rename (#1138).
|
||||||
|
- File information is now updated properly after reloading (#1149).
|
||||||
|
- Window widths are now calculated properly when `drawbox` is enabled (#1150).
|
||||||
|
- Line number widths are now calculated properly when there are exactly 10 entries (#1151).
|
||||||
|
- Preview is not redrawn in async shell commands (#1164).
|
||||||
|
- A small delay is added before showing loading text in preview pane to avoid flickering (#1154).
|
||||||
|
- Hard-coded box drawing characters are replaced with Tcell constants to enable the fallback mechanism (#1170).
|
||||||
|
- Option `relativenumber` now shows zero in the current line (#1171).
|
||||||
|
- Completion is not stuck in an infinite loop anymore when a match is longer than the window width (#1183).
|
||||||
|
- Completion now inserts the longest match even if there is no word before the cursor (#1184).
|
||||||
|
- Command `doc` should now work even if `lf` is not in the `PATH` variable (#1176).
|
||||||
|
- Directory option changes should not crash the program anymore (#1204).
|
||||||
|
- Option `selmode` is now validated for the accepted values (#1206).
|
||||||
|
|
||||||
|
## [r28](https://github.com/gokcehan/lf/releases/tag/r28)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Extension matching for colors and icons are now case insensitive (#908).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Three new commands `high`, `middle`, and `low` are added to move the current selection relative to the screen (#824).
|
||||||
|
- Backspace on empty prompt now switches to Normal mode (#836).
|
||||||
|
- A new `history` option is now added to be able to disable history (#866).
|
||||||
|
- A new special expansion `%S` spacer is added for `promptfmt` to be able to right align parts (#867).
|
||||||
|
- A new command-line command `cmd-menu-accept` is now added to accept the currently selected match (#934).
|
||||||
|
- Command-line commands should now be shown in completion for `map` and `cmap` (#934).
|
||||||
|
- Italic escape codes should now be working in previews (#936).
|
||||||
|
- Position and size information are now also passed to the `cleaner` script as arguments (#945).
|
||||||
|
- A new option `dirpreviews` is now added to also pass directories to the `previewer` script (#842).
|
||||||
|
- A new option `selmode` is now added to be able to limit the selection to the current directory (#849).
|
||||||
|
- User defined options with `user_` prefix are now supported (#865).
|
||||||
|
- Adding or removing `$`/`%`/`!`/`&` characters in `:` mode should now change the mode accordingly (#960).
|
||||||
|
- A new special command `on-select` is now added to be able to run a command after the selection changes (#864).
|
||||||
|
- Mouse support is extended to be able to click filenames for selection and opening (#963).
|
||||||
|
- Two new environment variables `lf_width` and `lf_height` are now exported for shell commands.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Option `tagfmt` can now be changed properly.
|
||||||
|
- User name, group name, and link count should now be displayed as before where available (#829).
|
||||||
|
- Tagging files with colons in their names should now work as expected (#857).
|
||||||
|
- Some multibyte characters should now be handled properly for completion (#934).
|
||||||
|
- Menu completion for a file in a subdirectory should now be working properly (#934).
|
||||||
|
- File completion should now be escaped properly in menu completion (#934).
|
||||||
|
- First use of `cmd-menu-complete-back` should now select the last completion as expected (#934).
|
||||||
|
- Broken symlinks should now be working properly in completion (#934).
|
||||||
|
- Files with stat errors should now be skipped properly in completion (#934).
|
||||||
|
- Empty search with `incsearch` option should now be handled properly (#944).
|
||||||
|
- History position is now also reset when leaving the command line (#953).
|
||||||
|
- Mouse drag events are now ignored properly to avoid command repetition (#962).
|
||||||
|
- Environment variables `HOME` and `USER` should now be used as fallback for locations on some systems (#972).
|
||||||
|
- File information is now displayed in the status line at first launch when there are no errors in the configuration file (#994).
|
||||||
|
|
||||||
|
## [r27](https://github.com/gokcehan/lf/releases/tag/r27)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Creation of log files are now disabled by default. Instead, a new command line option `-log` is provided.
|
||||||
|
- `copy` selections are now kept after `paste` (#745). You can use `map p :paste; clear` to get the old behavior.
|
||||||
|
- The socket file is now created in `XDG_RUNTIME_DIR` when set, with a fallback to the temporary directory otherwise.
|
||||||
|
- Directory counting with `dircounts` option is moved from UI drawing to directory reading to be run asynchronously without locking the UI. With this change, manual `reload` commands might be necessary when `dircounts` is changed at runtime. Indicators for errors are changed to `!` instead of `?` to distinguish them from missing values.
|
||||||
|
- The default icons are now replaced with ASCII characters to avoid font issues.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Files and options are now exported for `previewer` and `cleaner` scripts. For `cleaner` scripts, this can be used to detect if the file selection is changed or not (e.g. `$1 == $f`) and act accordingly (e.g. skip cleaning).
|
||||||
|
- A new `tempmarks` option is added to set some marks as temporary (#744).
|
||||||
|
- The pattern `*filename` is added for colors and icons.
|
||||||
|
- A new `calcdirsize` command is added to calculate directory sizes (#750).
|
||||||
|
- Two new options `infotimefmtnew` and `infotimefmtold` are added to configure the time format used in `info` (#751).
|
||||||
|
- Two new commands `jump-next` (default `]`) and `jump-prev` (default `[`) are added to navigate the jumplist (#755).
|
||||||
|
- Colors and icons file support is now added to be able to configure without environment variables. Example colors and icons files are added to the repository under `etc` directory. See the documentation for more information.
|
||||||
|
- For Windows, an example `open` command is now provided in the PowerShell example configuration (#765).
|
||||||
|
- Two new commands `scroll-up` (default `<c-y>`) and `scroll-down` (default `<c-e>`) are added to be able to scroll the file list without moving (#764).
|
||||||
|
- A new special command `on-quit` is added to be able to run a command before quitting.
|
||||||
|
- Two new commands `tag` and `tag-toggle` (default `t`) are now added to be able to tag files (#791).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `Chmod` calls in the codebase are now removed to avoid TOC/TOU exploits. Instead, file permissions are now set at file creation.
|
||||||
|
- Socket and log files are now created with only user permissions.
|
||||||
|
- On Windows, `PWD` variable is now quoted properly.
|
||||||
|
- Shell commands `%` and `&` are now run in a separate process group (#753).
|
||||||
|
- Navigation initialization is now delayed after the evaluation of configuration files to avoid startup races and redundant loadings (#759).
|
||||||
|
- The error message shown when the current working directory does not exist at startup is made more clear.
|
||||||
|
- Trailing slashes in `PWD` variable are now handled properly.
|
||||||
|
- Files with `stat` errors are now skipped while reading directories.
|
||||||
|
|
||||||
|
## [r26](https://github.com/gokcehan/lf/releases/tag/r26)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- On Windows, input handling is properly resumed after shell commands.
|
||||||
|
|
||||||
|
## [r25](https://github.com/gokcehan/lf/releases/tag/r25)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new `dironly` option is added to only show directories and hide regular files (#669).
|
||||||
|
- A new `dircache` option is added to disable caching of directories (#673).
|
||||||
|
- Two new commands `filter` and `setfilter` is added along with a new option `incfilter` and a `promptfmt` expansion `%F` to implement directory filtering feature (#667).
|
||||||
|
- A new special command `pre-cd` is added to run a command before a directory is changed (#685).
|
||||||
|
- `cmap` command now accepts all expressions similar to `map` (#686).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Marking a symlink directory should now save the symlink path instead of the target path (#659).
|
||||||
|
- A number of crashes have been fixed when the `hidden` option is changed.
|
||||||
|
|
||||||
|
## [r24](https://github.com/gokcehan/lf/releases/tag/r24)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Data directory is automatically created before the selection file is written.
|
||||||
|
- An error is returned for remote commands when the given ID is not connected to the server.
|
||||||
|
- Prompts longer than the width should not crash the program anymore.
|
||||||
|
|
||||||
|
## [r23](https://github.com/gokcehan/lf/releases/tag/r23)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- There has been some changes in the server protocol. Make sure to kill the old server process when you update to avoid errors.
|
||||||
|
- Server `load` and `save` commands are now removed. Instead a local file is used to record file selections (e.g. `~/.local/share/lf/files`). See the documentation for more information.
|
||||||
|
- Clients are now disconnected from server on quit. The old server `quit` command is renamed to `quit!` to act as a force quit by closing connected client connections first. A new `quit` command is added to only quit when there are no connected clients left.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new `autoquit` option is added to automatically quit the server when there are no connected clients left. This option is disabled by default to keep the old behavior. This is added as an option to avoid respawning server repeatedly when there is often a single client involved but more clients are spawned from time to time.
|
||||||
|
- A new `-single` command line flag is added to avoid spawning and/or connecting to server on startup. Remote commands would not work in this case as the client does not connect to a server. Local versions of internal `load` and `sync` commands are implemented properly.
|
||||||
|
- Errors for remote commands are now also shown in the output in addition to the server log file.
|
||||||
|
- Bright ANSI color escape codes (i.e. 90-97 and 100-107) are now supported.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Lookahead size for escape codes are increased to recognize longer escape codes used in some image previewers.
|
||||||
|
- The file preview cache is invalidated when the terminal height changes to fill the screen properly.
|
||||||
|
- The file preview cache is invalidated when the `drawbox` option changes and true image previews should be triggered to be drawn at updated positions.
|
||||||
|
- A crash scenario is fixed when `hidden` option is changed.
|
||||||
|
- Pane widths should now be calculated properly when big numbers are used in `ratios` (#622).
|
||||||
|
- The special bookmark `'` is now preserved properly after `sync` commands (#624).
|
||||||
|
- On some platforms, a bug has been fixed on the Tcell side to avoid an extra key press after terminal suspend/resume and the Tcell version used in `lf` is bumped accordingly to include the fix.
|
||||||
|
- The prompt line should now scroll accordingly when the text is wider than the screen.
|
||||||
|
- Text width in the prompt line should now be calculated properly when non-ASCII characters are involved.
|
||||||
|
- Erase line escape codes (i.e. `\033[K`) used in some command outputs should now be ignored properly.
|
||||||
|
|
||||||
|
## [r22](https://github.com/gokcehan/lf/releases/tag/r22)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new `-config` command line flag is added to use a custom config file path (#587).
|
||||||
|
- The current working directory is now exported as `PWD` environment variable (#591). Subshells in symlink directories should now start in their own paths properly.
|
||||||
|
- The initial working directory is now exported as `OLDPWD` environment variable.
|
||||||
|
- A new `shellflag` option is added to customize the shell flag used for passing commands (i.e. default `-c` for Unix and `/c` for Windows).
|
||||||
|
- Using the command `cmd-enter` during `find` and `find-back` now jumps to the first match (#605).
|
||||||
|
- A new `waitmsg` option is added to customize the prompt message after `shell-wait` commands (i.e. default `Press any key to continue`) (#604).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- A regression bug is fixed to print a newline in the prompt message properly after `shell-wait` commands.
|
||||||
|
- A regression bug is fixed to avoid CPU stuck at 100% when the terminal is closed unexpectedly.
|
||||||
|
- A regression bug is fixed to make shell commands use the alternate screen properly and keep the terminal history after quitting.
|
||||||
|
- Enter keypad terminfo sequence is now sent on startup so the `delete` key should be recognized properly in `st` terminal.
|
||||||
|
|
||||||
|
## [r21](https://github.com/gokcehan/lf/releases/tag/r21)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `cut` and `copy` do not follow symlinks anymore. Broken symlinks can now be selected for the `cut` and `copy` commands (#581).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- User name, group name, and hard link counts are now shown in the status line at the bottom when available.
|
||||||
|
- Number of selected, copied, and cut files are now shown in the ruler at the bottom when they are non-zero.
|
||||||
|
- Hard-coded shell commands with `stty` (Unix) and `pause` (Windows) to implement the `Press any key to continue` behavior are now implemented properly with a Go terminal handling library. With this change, the requirement for a POSIX compatible shell for `shell` option is now dropped and other shells can be used.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- A longstanding issue regarding UI suspend/resume for shell commands in MacOS is now fixed in Tcell.
|
||||||
|
- Renaming a symlink to its target or a symlink to another with the same target should now be handled properly (#581).
|
||||||
|
- Autocompletion in a directory containing a broken symlink should now work as intended (#581).
|
||||||
|
- Setting `shellopts` to empty in the configuration file should not pass an extra empty argument to shell commands anymore.
|
||||||
|
- Previously given tip to trap `SIGPIPE` in the preview script to enable caching is now updated in the documentation. Trapping the signal in the preview script avoids sending the signal to the program when enough lines are read. This may result in reading redundant lines especially for big files. The recommended method is now to add a trailing `|| true` to each command exiting with a non-zero return code after a `SIGPIPE`.
|
||||||
|
|
||||||
|
## [r20](https://github.com/gokcehan/lf/releases/tag/r20)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new `mouse` option is added to enable mouse events. This option is disabled by default to leave mouse events to the terminal. Also unbound mouse events when `mouse` is enabled should now show an `unknown mapping` error in the message line.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Newline characters in the output of `%` commands should no longer shift the content up which was a bug introduced in the previous release due to a fix to handle combining characters in texts.
|
||||||
|
- Redundant preview loadings for the `search` and `find` commands are now avoided (#569).
|
||||||
|
- Scanner now only considers ASCII characters for spaces and digits which should avoid unexpected splits in some non-ASCII inputs.
|
||||||
|
|
||||||
|
## [r19](https://github.com/gokcehan/lf/releases/tag/r19)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Changes have been made to enable the use of true image previews. See the documentation and the previews wiki page for more information.
|
||||||
|
- Non-zero exit codes should now make the preview volatile to avoid caching. Programs that may not behave well to `SIGPIPE` may trigger this behavior unintentionally. You may trap `SIGPIPE` in your preview script to get the old behavior.
|
||||||
|
- Preview scripts should now get as arguments the current file path, width, height, horizontal position, and vertical position. Note that height is still passed as an argument but its order is changed.
|
||||||
|
- A new `cleaner` option is added to set the path to a file to be executed when the preview is changed.
|
||||||
|
- Redundant preview loadings for movement commands are now avoided.
|
||||||
|
- Expansion `%w` in `promptfmt` is changed back to its old behavior without a trailing separator. Instead, a new expansion `%d` is added with a trailing separator (#545). Expansion `%w` is meant to be used to display the current working directory, whereas `%d%f` is meant to be used to display the current file.
|
||||||
|
- A new `LF_COLORS` environment variable is now checked to be able to make `lf` specific configurations. Also, environment variables for colors are now read cumulatively starting from the default behavior (i.e. default, `LSCOLORS`, `LS_COLORS`, `LF_COLORS`).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Full path, dir name, file name, and base name matching patterns are added to colors and icons. See the updated documentation for more information.
|
||||||
|
- PowerShell keybinding example has been added to `etc/lfcd.ps1` (#532).
|
||||||
|
- PowerShell autocompletion script has been added as `etc/lf.ps1` (#535).
|
||||||
|
- Multiple `-command` flags can now be given (#552).
|
||||||
|
- Basic mouse support has been added. Mouse buttons (e.g. `<m-1>` for primary button, `<m-2>` for secondary button, `<m-3>` for middle button etc.) and mouse wheels (e.g. `<m-up>` for wheel up, `<m-down>` for wheel down etc.) can be used in bindings.
|
||||||
|
- Commands `top` and `bottom` are now allowed in `cmap` mappings in addition to movement commands.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Extension sorting should now handle extensions with different lengths properly (#539).
|
||||||
|
- Heuristic used to show `info` should now take into account the `number` and `icons` options properly.
|
||||||
|
- The environment variable `id` is now set to the process ID instead to avoid two clients getting the same ID when launched at the same time (#550).
|
||||||
|
- Unicode combining characters in texts should now be displayed properly.
|
||||||
|
|
||||||
|
## [r18](https://github.com/gokcehan/lf/releases/tag/r18)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The `ignorecase` and `ignoredia` options should now also apply to sorting in addition to searching.
|
||||||
|
- The `ignoredia` option is now enabled by default to be consistent with `ignorecase`.
|
||||||
|
- The terminal UI library Tcell has been updated to version 2. This version highlights adding 24-bit true colors on Windows and better support for colors on Unix. The environment variable `TCELL_TRUECOLOR` is not required anymore so that terminal themes and true colors can be used at the same time.
|
||||||
|
- The deprecated option `color256` is now removed.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Two new command line commands `cmd-menu-complete` and `cmd-menu-complete-back` are added for completion menu cycling (#482).
|
||||||
|
- Simple configuration files for Windows `etc/lfrc.cmd.example` and `etc/lfrc.ps1.example` are now added to the repository.
|
||||||
|
- Bash completion script `etc/lf.bash` is now added to the repository.
|
||||||
|
- Time formats in `info` option should now show the year instead of `hh:mm` for times older than the current year.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Signals `SIGHUP`, `SIGQUIT`, and `SIGTERM` should now quit the program properly.
|
||||||
|
- Setting `info` to an empty value should not print errors to the log file anymore.
|
||||||
|
- Natural sorting is optimized to work faster using less memory.
|
||||||
|
- Files and directories that incorrectly show modification times in the future (e.g. Linux builtin exFAT driver) should not cause CPU hogging anymore.
|
||||||
|
- The keybinding example in `etc/lfcd.fish` is now updated to avoid hanging in shell commands.
|
||||||
|
- Using the `bottom` command immediately after startup should not crash the program anymore.
|
||||||
|
- Changing sorting options during sorting operations should not crash the program anymore.
|
||||||
|
- Output in `shell-pipe` commands now uses lazy redrawing so that verbose commands should not block the program anymore.
|
||||||
|
- The server is now daemonized properly on Unix so that it is not killed anymore when the controlling terminal is killed (#517).
|
||||||
|
|
||||||
|
## [r17](https://github.com/gokcehan/lf/releases/tag/r17)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The terminal UI library has been changed from Termbox to Tcell as the former has been unmaintained for a while (#439). Some of the changes are listed below, though the list may not be complete as this is a relatively big change.
|
||||||
|
- Some special key names are changed to be consistent with the Tcell documentation (e.g. `<bs>` renamed to `<backspace>`). On the other hand, there are also additional keybindings that were not available before (e.g. `<backtab>` for <kbd>Shift+Tab</kbd>). You can either check the Tcell documentation for the list of keys or hit the key combination in `lf` to read the name of the key from the `unknown mapping` error message.
|
||||||
|
- 24-bit true colors are now supported on Unix systems. See the updated documentation for more information. There is an ongoing version 2.0 of Tcell in development that we plan to switch to once it becomes stable and it is expected to add support for true colors in Windows consoles as well.
|
||||||
|
- Additional platforms are now supported and the list of pre-built binaries provided are updated accordingly.
|
||||||
|
- Wide characters are now displayed properly in Windows consoles.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Descriptions of commands and options are now added to the documentation. Undocumented behaviors should now be considered documentation bugs and they can be reported.
|
||||||
|
- Keys are now evaluated with a lazy drawing approach so `push` commands to set the prompt and pasting something to the command line should feel instantaneous.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Corrupted history files should no longer crash the program.
|
||||||
|
- The server now only listens connections from `localhost` on Windows so firewall permissions are not required anymore.
|
||||||
|
- `push` commands that change the operation mode should now work consistently as expected.
|
||||||
|
- Loading directories should now display the previous file list if any, which was a regression due to a bug fix in a previous release.
|
||||||
|
- `shell-pipe` commands should now automatically update previews when necessary.
|
||||||
|
- Errors from failed shell commands should not be overwritten by file information anymore.
|
||||||
|
- The server can now also be started automatically when the program is called with a relative path, which was a regression due to a bug fix in a previous release (#463).
|
||||||
|
- Environment variables are now exported automatically for preview scripts without having to call a shell command first (#468).
|
||||||
|
- The `<esc>` key can now be bound to be used on its own, instead of escaping a keybinding combination, which was a regression due to a bug fix in a previous release (#475).
|
||||||
|
- Changing the `hiddenfiles` option should now automatically trigger directory updates when necessary.
|
||||||
|
|
||||||
|
## [r16](https://github.com/gokcehan/lf/releases/tag/r16)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Option values are now available in shell commands as environment variables with a prefix of `lf_` (e.g. `$lf_hidden`, `$lf_ratios`) (#448).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Directories containing internal Windows links that show permission denied errors should now display properly.
|
||||||
|
|
||||||
|
## [r15](https://github.com/gokcehan/lf/releases/tag/r15)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The `toggle` command does not move the selection down anymore. The default binding for `<space>` is now assigned to `:toggle; down` instead to keep the default behavior same as before.
|
||||||
|
- The expansion `%w` in option `promptfmt` should now have a trailing slash. The default value of `promptfmt` is now changed accordingly, and should not display double slashes in the root directory anymore.
|
||||||
|
- The key `<esc>` is now used as the escape key. It should not display an error message when used to cancel a keybinding menu as before. However, it is not possible to bind `<esc>` key to another command anymore.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Symbolic link destinations are now shown in the bottom status line (#374).
|
||||||
|
- A new `hiddenfiles` option which takes a list of globs is implemented to customize which files should be `hidden` (#372).
|
||||||
|
- Expressions consisting of multiple commands can now use counts (#394).
|
||||||
|
- Moving operations now fall back to copy and then delete strategy automatically for cross-device linking.
|
||||||
|
- The `hidden` option now works in Windows.
|
||||||
|
- The `toggle` command can now take optional arguments to toggle given names instead of the current file (#409).
|
||||||
|
- A new option `truncatechar` is implemented to customize the truncate character used in long filenames (#417).
|
||||||
|
- Copy and move operations now display a success message when they are finished (#427).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `SIGHUP` and `SIGTERM` signals are now properly handled. Log files should not remain when terminals are directly closed (#305).
|
||||||
|
- The `info` option should now align properly when used with the `number` and `relativenumber` options (#373).
|
||||||
|
- Tilde (`~`) is now only expanded at the beginning of the path for the `cd` and `select` commands (#373).
|
||||||
|
- The `rename` command should now work properly with names differing only cases on case-insensitive filesystems.
|
||||||
|
- Tab characters are now expanded to spaces in Windows.
|
||||||
|
- The `incsearch` option now respects the search direction accordingly.
|
||||||
|
- The server is now started in the home folder and will not hold mounted filesystems busy.
|
||||||
|
- Trailing spaces in configuration files do not confuse the parser anymore.
|
||||||
|
- Termbox version is updated to fix a keyboard problem in FreeBSD (#404).
|
||||||
|
- Async commands do not leave zombie processes anymore (#407).
|
||||||
|
- The `hidden` option now works consistently as expected when set at the initial launch.
|
||||||
|
- The `rename` command should now select the new file after the operation.
|
||||||
|
- The `rename` command should now handle absolute paths properly.
|
||||||
|
- The `select` command should now work properly on loading directories. Custom commands that select a file after an operation should now work properly without an explicit `load` operation beforehand.
|
||||||
|
- Previous errors in the bottom message line should not persist through the prompt usage anymore.
|
||||||
|
- The `push` command should not fail with non-ASCII characters anymore.
|
||||||
|
- The `select` command should not fail with broken links anymore.
|
||||||
|
- The `load` command should not clear toggled broken links anymore.
|
||||||
|
- Copy and move operations do not overwrite broken links anymore.
|
||||||
|
|
||||||
|
## [r14](https://github.com/gokcehan/lf/releases/tag/r14)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- The `delete` command now shows a prompt with the current filename or the number of selected files (#206).
|
||||||
|
- Backslash can now be escaped with a backslash even without quotes.
|
||||||
|
- A new desktop entry file `lf.desktop` is added (#222).
|
||||||
|
- Three new `sortby` types are added, access time (i.e. `atime`), change time (i.e. `ctime`) (#226), and extension (i.e. `ext`) (#230). New default keybindings are added for these sorts correspondingly (i.e. `sa`, `sc`, and `se`). The `info` option can now also contain `atime` and `ctime` values accordingly.
|
||||||
|
- A new shell completion for `zsh` is added to `etc/lf.zsh` (#239).
|
||||||
|
- The `delete` command now works asynchronously and shows the progress (#238).
|
||||||
|
- Completion and directory change scripts are added for `csh` and `tcsh` as `etc/lf.csh` and `etc/lfcd.csh` respectively (#264).
|
||||||
|
- A new special command `on-cd` is added to run a shell command when the directory is changed. See the documentation for more information (#291).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Some directories with special permissions that previously show a file icon now shows a directory icon properly.
|
||||||
|
- The `etc/lfcd.cmd` script can now also change to a different volume drive (#221).
|
||||||
|
- The proper use of `setsid` for opening files is now added to the example configuration and the documentation.
|
||||||
|
- The home directory abbreviation `~` is now only applied properly to paths starting with the home directory (#241).
|
||||||
|
- The `rename` command now cancels the operation if the old and new paths are the same (#266).
|
||||||
|
- Autocompletion and word movements should now work properly with all Unicode characters.
|
||||||
|
- The `shell-pipe` command which was broken some time ago should now work as expected.
|
||||||
|
- The `$TERM` environment variable can now work with values containing `tmux` with custom `$TERMINFO` values. @doronbehar now maintains a Termbox fork for `lf` (https://github.com/doronbehar/termbox-go).
|
||||||
|
|
||||||
|
## [r13](https://github.com/gokcehan/lf/releases/tag/r13)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new `wrapscroll` option is added to wrap top and bottom while scrolling (#166).
|
||||||
|
- The `up`, `down` movement commands and their variants, `updir`, and `open` are now allowed in `cmap` mappings.
|
||||||
|
- Two new `glob-select` and `glob-unselect` commands are added to use globbing for toggling files (#184).
|
||||||
|
- A new `mark-remove` (default `"`) command is added to allow removing marks (#190).
|
||||||
|
- Icon support is added with the `icon` option. See the wiki page for more details.
|
||||||
|
- A new builtin `rename` command is added (#197).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The `cmd-history-next` command now remains in Command-line mode after the last item (#168).
|
||||||
|
- The `select` command does not change directories anymore when used on a directory.
|
||||||
|
- The working directory is now changed to the first argument when it is a directory.
|
||||||
|
- The `ratios` option is now checked before `preview` to avoid crashes (#174).
|
||||||
|
- Previous error messages are now cleared after successful commands (#192).
|
||||||
|
- Symlink to directories are now colored as symlinks (#195).
|
||||||
|
- Permission errors for directories are now displayed properly instead of showing as empty (#203).
|
||||||
|
|
||||||
|
## [r12](https://github.com/gokcehan/lf/releases/tag/r12)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Go modules replaced `godep` for dependency management. Package maintainers may need to update accordingly.
|
||||||
|
- A new `errorfmt` option is added to customize the colors and attributes of error messages.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Autocompletion for searches now complete filenames instead of commands.
|
||||||
|
- Permanent environment variables (e.g. `$id`, `$EDITOR`, `$LF_LEVEL`) are now exported on startup so they can be used in preview scripts without running a shell command first.
|
||||||
|
- On Windows, quotes are added to the exported values `$f`, `$fs`, and `$fx` to handle filenames with spaces properly.
|
||||||
|
- On Windows, filenames starting with `.` characters are now shown to avoid crashes when filenames show up as empty.
|
||||||
|
|
||||||
|
## [r11](https://github.com/gokcehan/lf/releases/tag/r11)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Copy and move operations are now implemented as builtins instead of using the underlying shell primitives (i.e. `cp` and `mv`). Users who want the old behavior can define a custom `paste` command. See the updated documentation for more information. Please report bugs regarding this change.
|
||||||
|
- Preview messages (i.e. `empty`, `binary`, and `loading...`) are now shown with the reverse attribute.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Copy and move operations now run asynchronously and the progress is shown in the bottom ruler.
|
||||||
|
- Two new commands `echomsg` and `echoerr` are added to print a message to the message line and to the log file at the same time.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Terminal initialization errors are now shown in the terminal instead of the log file.
|
||||||
|
|
||||||
|
## [r10](https://github.com/gokcehan/lf/releases/tag/r10)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The ability to map Normal mode commands in `cmap` is removed. This has caused a number of bugs in the previous release. A different mechanism for a similar functionality is planned.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new command line flag `-command` has been added to execute a command on client initialization (#135).
|
||||||
|
- A `select` command is now executed after initialization if the first command line argument is a file.
|
||||||
|
- A prompting mechanism has been added to the builtin `delete` command.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Input and output in `shell-pipe` commands were broken with the `cmap` patch. This should now work as before.
|
||||||
|
- Some `push` commands were broken with the `cmap` patch and sometimes ignored Command-line mode for some keys to execute as in Normal mode. This should now work as before.
|
||||||
|
- `read` and shell commands should now also work when typed manually (e.g. typing `:shell` should switch the prefix to `$`).
|
||||||
|
- Configuration files are now read after initialization.
|
||||||
|
- Background colors are removed from defaults to avoid confusion with selection highlighting.
|
||||||
|
|
||||||
|
## [r9](https://github.com/gokcehan/lf/releases/tag/r9)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The default number of colors is set to 8 to have better defaults in some terminals. A new option `color256` is added to use 256 colors instead. Users who want the old behavior should enable this option in their configuration files.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new `incsearch` option is added to enable incremental matching while searching.
|
||||||
|
- Two new options `ignoredia` and `smartdia` are added to ignore diacritics in Latin letters for `search` and `find` (#118).
|
||||||
|
- A new builtin `delete` command is added for file deletion (#121). This command is not assigned to a key by default to prevent accidental deletions. In the future, a prompting mechanism may be added to this command for more safety.
|
||||||
|
- Normal mode commands can now be used in `cmap` which can be used to immediately finish Command-line mode and execute a Normal mode command afterwards.
|
||||||
|
- A new `fish` completion script is added to the `etc` folder (#131).
|
||||||
|
- Two new options `number` and `relativenumber` are added to enable line numbers in directories (#133).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Autocompletion should now show only a single match for redefined builtin commands.
|
||||||
|
|
||||||
|
## [r8](https://github.com/gokcehan/lf/releases/tag/r8)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Four new commands `find`, `find-back`, `find-next`, and `find-prev` are added to implement file finding. Two options `anchorfind` and `findlen` are added to customize the behavior of these commands.
|
||||||
|
- A new `quit` command is added to the server protocol to quit the server.
|
||||||
|
- A new `$LF_LEVEL` environment variable is added to show the nesting level.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The `load` and `reload` commands now work properly when the current directory is deleted. Also `lf` does not start in deleted directories anymore.
|
||||||
|
- The server is now started as a detached process in Windows so its lifetime is not tied to the command line window anymore.
|
||||||
|
- Clients now try to reconnect to the server at startup with exponentially increasing intervals when they fail. This is to avoid connection failures due to the server not being ready for the first client that automatically starts the server.
|
||||||
|
- The old index is now kept when the current selection is deleted.
|
||||||
|
- The `shell-pipe` command now triggers `load` instead of `reload`.
|
||||||
|
- Error messages are now more informative when `lf` fails to start due to either `$HOME` or `$USER` variables being empty or not set.
|
||||||
|
- Searching for the next/previous item is now based on the direction of the initial search.
|
||||||
|
|
||||||
|
## [r7](https://github.com/gokcehan/lf/releases/tag/r7)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The system-wide configuration path on Unix is changed from `/etc/lfrc` to `/etc/lf/lfrc`.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A man page is now automatically generated from the documentation which can be installed to make the documentation available with the `man` command. On a related note, there is now a packaging guide section in packages wiki page.
|
||||||
|
- A new `doc` command (default `<f-1>`) is added to view the documentation in a pager.
|
||||||
|
- Commands `mark-save` (default `m`) and `mark-load` (default `'`) are added to implement builtin bookmarks. Marks are saved in a file in the data folder which can be found in the documentation.
|
||||||
|
- The history is now saved in a file in the data folder which can be found in the documentation.
|
||||||
|
|
||||||
|
## [r6](https://github.com/gokcehan/lf/releases/tag/r6)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The `yank`, `delete`, and `put` commands are renamed to `copy`, `cut`, and `paste` respectively. In the example configuration, the `remove` command is renamed to `delete`.
|
||||||
|
- The special command `open-file` to configure file opening is renamed to `open`.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new option `shellopts` is added to be able to pass command line arguments to the shell interpreter (i.e. `<shell> <shellopts> -c <cmd> -- <args>`) which is useful to set safety options for all shell commands (i.e. `sh -eu ...`). See the example configuration file for more information.
|
||||||
|
- The special keys `<home>`, `<end>`, `<pgup>`, and `<pgdn>` are mapped to the `top`, `bottom`, `page-up`, and `page-down` commands respectively by default.
|
||||||
|
- A new command `source` is added to read a configuration file.
|
||||||
|
- Support is added to read a system-wide configuration file on startup located in `/etc/lfrc` on Unix and `C:\ProgramData\lf\lfrc` on Windows. The documentation is updated to show the locations of all configuration files.
|
||||||
|
- Environment variables used for configuration (i.e. `$EDITOR`, `$PAGER`, `$SHELL`) are set to their default values when they are not set or empty and they are exported to shell commands.
|
||||||
|
- A new environment variable `$OPENER` is added to configure the default file opener using the previous default values and it is exported to shell commands.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Executable completion now works on Windows as well.
|
||||||
|
|
||||||
|
## [r5](https://github.com/gokcehan/lf/releases/tag/r5)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- The server is automatically restarted on startup if it does not work anymore.
|
||||||
|
- A new option `period` is added to set time duration in seconds for periodic refreshes. Setting the value of this option to zero disables periodic refreshes which is the default behavior.
|
||||||
|
- A new command `load` is added to refresh only modified files and directories which is more efficient than `reload` command.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `cmd-word-back` does not change the command line anymore.
|
||||||
|
- Modified files and directories are automatically detected and refreshed when they are loaded from cache.
|
||||||
|
- All clients are now refreshed when the `put` command is used.
|
||||||
|
- The correct hidden parent is selected when the `hidden` option is changed.
|
||||||
|
- The preview is properly updated when the `hidden` option is changed.
|
||||||
|
|
||||||
|
## [r4](https://github.com/gokcehan/lf/releases/tag/r4)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The following commands are renamed for clarity and consistency:
|
||||||
|
- `bot` is renamed to `bottom`
|
||||||
|
- `cmd-delete-word` is renamed to `cmd-delete-unix-word`
|
||||||
|
- `cmd-beg` is renamed to `cmd-home`
|
||||||
|
- `cmd-delete-beg` is renamed to `cmd-delete-home`
|
||||||
|
- `cmd-comp` is renamed to `cmd-complete`
|
||||||
|
- `cmd-hist-next` is renamed to `cmd-history-next`
|
||||||
|
- `cmd-hist-prev` is renamed to `cmd-history-prev`
|
||||||
|
- `cmd-put` is renamed to `cmd-yank`
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for alt key bindings have been added using the commonly used escape delaying mechanism. The delay value is set to 100ms which is also used for other escape codes in Termbox. Keys are named with an `a` prefix, as in `<a-f>` for the `alt` and `f` keys. Also note that the old mechanism for alt keybindings on 8-bit terminals still works as before.
|
||||||
|
- The following command line commands and their default alt keybindings have been added:
|
||||||
|
- `cmd-word` with `<a-f>`
|
||||||
|
- `cmd-word-back` with `<a-b>`
|
||||||
|
- `cmd-capitalize-word` with `<a-c>`
|
||||||
|
- `cmd-delete-word` with `<a-d>`
|
||||||
|
- `cmd-uppercase-word` with `<a-u>`
|
||||||
|
- `cmd-lowercase-word` with `<a-l>`
|
||||||
|
- `cmd-transpose-word` with `<a-t>`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The default editor, pager, and opener commands should now work in Windows. Opener still only works with paths without spaces though.
|
||||||
|
- 8-bit color codes and attributes are not confused anymore.
|
||||||
|
- History selection is disabled when a `shell-pipe` command is running.
|
||||||
|
- Searches are now excluded from the history.
|
||||||
|
|
||||||
|
## [r3](https://github.com/gokcehan/lf/releases/tag/r3)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Command counts are now only applied for the `up`/`down` (and variants), `updir`, `toggle`, `search-next`, and `search-prev` commands. These commands are now handled more efficiently when used with counts.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Pressed keys are now shown in the ruler when they are not matched yet.
|
||||||
|
- A new builtin `draw` command has been added which is more efficient than the `redraw` command. The latter is replaced with the former in many places to prevent flickers on the screen.
|
||||||
|
- Support for the `$LS_COLORS` and `$LSCOLORS` environment variables are added for color customization (#96). See the updated documentation for more information.
|
||||||
|
- A new option `drawbox` is added to draw a box around panes.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Resize events that change the height are now handled properly.
|
||||||
|
- Changes in sorting methods and options are checked for cached directories and these directories are sorted again if necessary while loading.
|
||||||
|
- A `~` character is added as a suffix to file names when they do not fit in the window.
|
||||||
|
|
||||||
|
## [r2](https://github.com/gokcehan/lf/releases/tag/r2)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Shell command names are shortened (e.g. `read-shell-wait` is renamed to `shell-wait`).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new shell command type named `shell-pipe` is introduced that runs with the UI. See the updated documentation for the motivation and some example use cases.
|
||||||
|
- A new command named `cmd-interrupt` (default `<c-c>`) is introduced to interrupt the current `shell-pipe` command.
|
||||||
|
- A new command named `select` is introduced that changes the current file selection to its argument.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Running `cmd-hist-prev` in Normal mode now always starts with the last item to avoid confusion. Running `cmd-hist-next` in Normal mode now has no effect for consistency.
|
||||||
|
|
||||||
|
## [r1](https://github.com/gokcehan/lf/releases/tag/r1)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Initial release
|
||||||
@@ -391,6 +391,7 @@ func (app *app) loop() {
|
|||||||
if ok {
|
if ok {
|
||||||
d.ind = prev.ind
|
d.ind = prev.ind
|
||||||
d.pos = prev.pos
|
d.pos = prev.pos
|
||||||
|
d.visualAnchor = min(prev.visualAnchor, len(d.files)-1)
|
||||||
d.filter = prev.filter
|
d.filter = prev.filter
|
||||||
d.sort()
|
d.sort()
|
||||||
d.sel(prev.name(), app.nav.height)
|
d.sel(prev.name(), app.nav.height)
|
||||||
@@ -426,7 +427,7 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.watchDir(d)
|
app.watchDir(d)
|
||||||
|
onLoad(app, d.fileNames())
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
case r := <-app.nav.regChan:
|
case r := <-app.nav.regChan:
|
||||||
app.nav.regCache[r.path] = r
|
app.nav.regCache[r.path] = r
|
||||||
@@ -435,6 +436,9 @@ func (app *app) loop() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
if r.path == curr.path {
|
if r.path == curr.path {
|
||||||
app.ui.regPrev = r
|
app.ui.regPrev = r
|
||||||
|
if gOpts.sixel {
|
||||||
|
app.ui.sxScreen.forceClear = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,15 +465,24 @@ func (app *app) loop() {
|
|||||||
if app.ui.msgIsStat {
|
if app.ui.msgIsStat {
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLoad(app, []string{f.path})
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
case path := <-app.nav.delChan:
|
case path := <-app.nav.delChan:
|
||||||
delete(app.nav.dirCache, path)
|
deletePathRecursive(app.nav.selections, path)
|
||||||
delete(app.nav.regCache, path)
|
|
||||||
|
|
||||||
delete(app.nav.selections, path)
|
|
||||||
if len(app.nav.selections) == 0 {
|
if len(app.nav.selections) == 0 {
|
||||||
app.nav.selectionInd = 0
|
app.nav.selectionInd = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deletePathRecursive(app.nav.regCache, path)
|
||||||
|
|
||||||
|
deletePathRecursive(app.nav.dirCache, path)
|
||||||
|
currPath := app.nav.currDir().path
|
||||||
|
if currPath == path || strings.HasPrefix(currPath, path+string(filepath.Separator)) {
|
||||||
|
if wd, err := os.Getwd(); err == nil {
|
||||||
|
app.nav.getDirs(wd)
|
||||||
|
}
|
||||||
|
}
|
||||||
case ev := <-app.ui.evChan:
|
case ev := <-app.ui.evChan:
|
||||||
e := app.ui.readEvent(ev, app.nav)
|
e := app.ui.readEvent(ev, app.nav)
|
||||||
if e == nil {
|
if e == nil {
|
||||||
@@ -540,13 +553,25 @@ func (app *app) runCmdSync(cmd *exec.Cmd, pause_after bool) {
|
|||||||
func (app *app) runShell(s string, args []string, prefix string) {
|
func (app *app) runShell(s string, args []string, prefix string) {
|
||||||
app.nav.exportFiles()
|
app.nav.exportFiles()
|
||||||
app.ui.exportSizes()
|
app.ui.exportSizes()
|
||||||
app.ui.exportMode()
|
app.exportMode()
|
||||||
|
exportLfPath()
|
||||||
exportOpts()
|
exportOpts()
|
||||||
|
|
||||||
gState.mutex.Lock()
|
gState.mutex.Lock()
|
||||||
gState.data["maps"] = listBinds(gOpts.keys)
|
gState.data["maps"] = listBinds(map[string]map[string]expr{
|
||||||
gState.data["cmaps"] = listBinds(gOpts.cmdkeys)
|
"n": gOpts.nkeys,
|
||||||
gState.data["cmds"] = listCmds()
|
"v": gOpts.vkeys,
|
||||||
|
})
|
||||||
|
gState.data["nmaps"] = listBinds(map[string]map[string]expr{
|
||||||
|
"n": gOpts.nkeys,
|
||||||
|
})
|
||||||
|
gState.data["vmaps"] = listBinds(map[string]map[string]expr{
|
||||||
|
"v": gOpts.vkeys,
|
||||||
|
})
|
||||||
|
gState.data["cmaps"] = listBinds(map[string]map[string]expr{
|
||||||
|
"c": gOpts.cmdkeys,
|
||||||
|
})
|
||||||
|
gState.data["cmds"] = listCmds(gOpts.cmds)
|
||||||
gState.data["jumps"] = listJumps(app.nav.jumpList, app.nav.jumpListInd)
|
gState.data["jumps"] = listJumps(app.nav.jumpList, app.nav.jumpListInd)
|
||||||
gState.data["history"] = listHistory(app.cmdHistory)
|
gState.data["history"] = listHistory(app.cmdHistory)
|
||||||
gState.data["files"] = listFilesInCurrDir(app.nav)
|
gState.data["files"] = listFilesInCurrDir(app.nav)
|
||||||
@@ -594,8 +619,8 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
normal(app)
|
normal(app)
|
||||||
app.cmd = cmd
|
app.cmd = cmd
|
||||||
app.cmdOutBuf = nil
|
app.cmdOutBuf = nil
|
||||||
app.ui.msg = ""
|
|
||||||
app.ui.cmdPrefix = ">"
|
app.ui.cmdPrefix = ">"
|
||||||
|
app.ui.echo("")
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
eol := false
|
eol := false
|
||||||
@@ -650,3 +675,43 @@ func (app *app) watchDir(dir *dir) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (app *app) exportMode() {
|
||||||
|
getMode := func() string {
|
||||||
|
if strings.HasPrefix(app.ui.cmdPrefix, "delete") {
|
||||||
|
return "delete"
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(app.ui.cmdPrefix, "replace") || strings.HasPrefix(app.ui.cmdPrefix, "create") {
|
||||||
|
return "rename"
|
||||||
|
}
|
||||||
|
|
||||||
|
switch app.ui.cmdPrefix {
|
||||||
|
case "filter: ":
|
||||||
|
return "filter"
|
||||||
|
case "find: ", "find-back: ":
|
||||||
|
return "find"
|
||||||
|
case "mark-save: ", "mark-load: ", "mark-remove: ":
|
||||||
|
return "mark"
|
||||||
|
case "rename: ":
|
||||||
|
return "rename"
|
||||||
|
case "/", "?":
|
||||||
|
return "search"
|
||||||
|
case ":":
|
||||||
|
return "command"
|
||||||
|
case "$", "%", "!", "&":
|
||||||
|
return "shell"
|
||||||
|
case ">":
|
||||||
|
return "pipe"
|
||||||
|
case "":
|
||||||
|
if app.nav.isVisualMode() {
|
||||||
|
return "visual"
|
||||||
|
}
|
||||||
|
return "normal"
|
||||||
|
default:
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Setenv("lf_mode", getMode())
|
||||||
|
}
|
||||||
+13
-4
@@ -14,6 +14,8 @@ var (
|
|||||||
"set",
|
"set",
|
||||||
"setlocal",
|
"setlocal",
|
||||||
"map",
|
"map",
|
||||||
|
"nmap",
|
||||||
|
"vmap",
|
||||||
"cmap",
|
"cmap",
|
||||||
"cmd",
|
"cmd",
|
||||||
"quit",
|
"quit",
|
||||||
@@ -36,7 +38,6 @@ var (
|
|||||||
"low",
|
"low",
|
||||||
"toggle",
|
"toggle",
|
||||||
"invert",
|
"invert",
|
||||||
"invert-below",
|
|
||||||
"unselect",
|
"unselect",
|
||||||
"glob-select",
|
"glob-select",
|
||||||
"glob-unselect",
|
"glob-unselect",
|
||||||
@@ -80,6 +81,7 @@ var (
|
|||||||
"mark-remove",
|
"mark-remove",
|
||||||
"tag",
|
"tag",
|
||||||
"tag-toggle",
|
"tag-toggle",
|
||||||
|
"addcustominfo",
|
||||||
"tty-write",
|
"tty-write",
|
||||||
"cmd-escape",
|
"cmd-escape",
|
||||||
"cmd-complete",
|
"cmd-complete",
|
||||||
@@ -109,6 +111,11 @@ var (
|
|||||||
"cmd-capitalize-word",
|
"cmd-capitalize-word",
|
||||||
"cmd-uppercase-word",
|
"cmd-uppercase-word",
|
||||||
"cmd-lowercase-word",
|
"cmd-lowercase-word",
|
||||||
|
"visual",
|
||||||
|
"visual-accept",
|
||||||
|
"visual-unselect",
|
||||||
|
"visual-discard",
|
||||||
|
"visual-change",
|
||||||
}
|
}
|
||||||
|
|
||||||
gOptWords = getOptWords(gOpts)
|
gOptWords = getOptWords(gOpts)
|
||||||
@@ -328,7 +335,7 @@ func completeCmd(acc []rune) (matches []string, longestAcc []rune) {
|
|||||||
case "set":
|
case "set":
|
||||||
matches, longest = matchWord(f[1], gOptWords)
|
matches, longest = matchWord(f[1], gOptWords)
|
||||||
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
|
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
|
||||||
case "map", "cmap", "cmd":
|
case "map", "nmap", "vmap", "cmap", "cmd":
|
||||||
longestAcc = acc
|
longestAcc = acc
|
||||||
default:
|
default:
|
||||||
matches, longest = matchFile(f[len(f)-1])
|
matches, longest = matchFile(f[len(f)-1])
|
||||||
@@ -339,16 +346,18 @@ func completeCmd(acc []rune) (matches []string, longestAcc []rune) {
|
|||||||
case "setlocal":
|
case "setlocal":
|
||||||
matches, longest = matchWord(f[2], gLocalOptWords)
|
matches, longest = matchWord(f[2], gLocalOptWords)
|
||||||
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
|
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
|
||||||
case "map", "cmap":
|
case "map", "nmap", "vmap", "cmap":
|
||||||
matches, longest = matchCmd(f[2])
|
matches, longest = matchCmd(f[2])
|
||||||
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
|
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
|
||||||
|
case "addcustominfo":
|
||||||
|
longestAcc = acc
|
||||||
default:
|
default:
|
||||||
matches, longest = matchFile(f[len(f)-1])
|
matches, longest = matchFile(f[len(f)-1])
|
||||||
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
|
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
switch f[0] {
|
switch f[0] {
|
||||||
case "set", "setlocal", "map", "cmap", "cmd":
|
case "set", "setlocal", "map", "nmap", "vmap", "cmap", "cmd":
|
||||||
longestAcc = acc
|
longestAcc = acc
|
||||||
default:
|
default:
|
||||||
matches, longest = matchFile(f[len(f)-1])
|
matches, longest = matchFile(f[len(f)-1])
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -54,30 +55,22 @@ func copySize(srcs []string) (int64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan int64) error {
|
func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan int64) error {
|
||||||
var dst_mode os.FileMode = 0o666
|
|
||||||
preserve_timestamps := false
|
|
||||||
for _, s := range preserve {
|
|
||||||
switch s {
|
|
||||||
case "timestamps":
|
|
||||||
preserve_timestamps = true
|
|
||||||
case "mode":
|
|
||||||
dst_mode = info.Mode()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
r, err := os.Open(src)
|
r, err := os.Open(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
|
|
||||||
|
var dst_mode os.FileMode = 0o666
|
||||||
|
if slices.Contains(preserve, "mode") {
|
||||||
|
dst_mode = info.Mode()
|
||||||
|
}
|
||||||
w, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, dst_mode)
|
w, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, dst_mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = io.Copy(NewProgressWriter(w, nums), r)
|
if _, err := io.Copy(NewProgressWriter(w, nums), r); err != nil {
|
||||||
if err != nil {
|
|
||||||
w.Close()
|
w.Close()
|
||||||
os.Remove(dst)
|
os.Remove(dst)
|
||||||
return err
|
return err
|
||||||
@@ -88,10 +81,9 @@ func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan in
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if preserve_timestamps {
|
if slices.Contains(preserve, "timestamps") {
|
||||||
ts := times.Get(info)
|
atime := times.Get(info).AccessTime()
|
||||||
mtime := info.ModTime()
|
mtime := info.ModTime()
|
||||||
atime := ts.AccessTime()
|
|
||||||
if err := os.Chtimes(dst, atime, mtime); err != nil {
|
if err := os.Chtimes(dst, atime, mtime); err != nil {
|
||||||
os.Remove(dst)
|
os.Remove(dst)
|
||||||
return err
|
return err
|
||||||
@@ -106,12 +98,13 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
errs = make(chan error, 1024)
|
errs = make(chan error, 1024)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
dirInfos := make(map[string]os.FileInfo)
|
||||||
|
|
||||||
for _, src := range srcs {
|
for _, src := range srcs {
|
||||||
file := filepath.Base(src)
|
file := filepath.Base(src)
|
||||||
dst := filepath.Join(dstDir, file)
|
dst := filepath.Join(dstDir, file)
|
||||||
|
|
||||||
lstat, err := os.Lstat(dst)
|
if lstat, err := os.Lstat(dst); err == nil {
|
||||||
if !os.IsNotExist(err) {
|
|
||||||
ext := getFileExtension(lstat)
|
ext := getFileExtension(lstat)
|
||||||
basename := file[:len(file)-len(ext)]
|
basename := file[:len(file)-len(ext)]
|
||||||
var newPath string
|
var newPath string
|
||||||
@@ -137,12 +130,20 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
newPath := filepath.Join(dst, rel)
|
newPath := filepath.Join(dst, rel)
|
||||||
if info.IsDir() {
|
switch {
|
||||||
if err := os.MkdirAll(newPath, info.Mode()); err != nil {
|
case info.IsDir():
|
||||||
|
var dst_mode os.FileMode = os.ModePerm
|
||||||
|
if slices.Contains(preserve, "mode") {
|
||||||
|
dst_mode = info.Mode()
|
||||||
|
}
|
||||||
|
if err := os.MkdirAll(newPath, dst_mode); err != nil {
|
||||||
errs <- fmt.Errorf("mkdir: %s", err)
|
errs <- fmt.Errorf("mkdir: %s", err)
|
||||||
}
|
}
|
||||||
|
if slices.Contains(preserve, "timestamps") {
|
||||||
|
dirInfos[newPath] = info
|
||||||
|
}
|
||||||
nums <- info.Size()
|
nums <- info.Size()
|
||||||
} else if info.Mode()&os.ModeSymlink != 0 { /* Symlink */
|
case info.Mode()&os.ModeSymlink != 0:
|
||||||
if rlink, err := os.Readlink(path); err != nil {
|
if rlink, err := os.Readlink(path); err != nil {
|
||||||
errs <- fmt.Errorf("symlink: %s", err)
|
errs <- fmt.Errorf("symlink: %s", err)
|
||||||
} else {
|
} else {
|
||||||
@@ -151,7 +152,7 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nums <- info.Size()
|
nums <- info.Size()
|
||||||
} else {
|
default:
|
||||||
if err := copyFile(path, newPath, preserve, info, nums); err != nil {
|
if err := copyFile(path, newPath, preserve, info, nums); err != nil {
|
||||||
errs <- fmt.Errorf("copy: %s", err)
|
errs <- fmt.Errorf("copy: %s", err)
|
||||||
}
|
}
|
||||||
@@ -160,6 +161,14 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for path, info := range dirInfos {
|
||||||
|
atime := times.Get(info).AccessTime()
|
||||||
|
mtime := info.ModTime()
|
||||||
|
if err := os.Chtimes(path, atime, mtime); err != nil {
|
||||||
|
errs <- fmt.Errorf("chtimes: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
close(errs)
|
close(errs)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ The following commands are provided by lf:
|
|||||||
middle (default 'M')
|
middle (default 'M')
|
||||||
low (default 'L')
|
low (default 'L')
|
||||||
toggle
|
toggle
|
||||||
|
visual (default 'V')
|
||||||
invert (default 'v')
|
invert (default 'v')
|
||||||
invert-below
|
|
||||||
unselect (default 'u')
|
unselect (default 'u')
|
||||||
glob-select
|
glob-select
|
||||||
glob-unselect
|
glob-unselect
|
||||||
@@ -102,9 +102,17 @@ The following commands are provided by lf:
|
|||||||
mark-remove (modal) (default '"')
|
mark-remove (modal) (default '"')
|
||||||
tag
|
tag
|
||||||
tag-toggle (default 't')
|
tag-toggle (default 't')
|
||||||
|
addcustominfo
|
||||||
tty-write
|
tty-write
|
||||||
|
|
||||||
The following command line commands are provided by lf:
|
The following Visual mode commands are provided by lf:
|
||||||
|
|
||||||
|
visual-accept (default 'V')
|
||||||
|
visual-unselect
|
||||||
|
visual-discard (default '<esc>')
|
||||||
|
visual-change (default 'o')
|
||||||
|
|
||||||
|
The following Command-line mode commands are provided by lf:
|
||||||
|
|
||||||
cmd-escape (default '<esc>')
|
cmd-escape (default '<esc>')
|
||||||
cmd-complete (default '<tab>')
|
cmd-complete (default '<tab>')
|
||||||
@@ -202,6 +210,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
truncatechar string (default '~')
|
truncatechar string (default '~')
|
||||||
truncatepct int (default 100)
|
truncatepct int (default 100)
|
||||||
|
visualfmt string (default "\033[7;36m")
|
||||||
waitmsg string (default 'Press any key to continue')
|
waitmsg string (default 'Press any key to continue')
|
||||||
watch bool (default false)
|
watch bool (default false)
|
||||||
wrapscan bool (default true)
|
wrapscan bool (default true)
|
||||||
@@ -212,6 +221,7 @@ The following environment variables are exported for shell commands:
|
|||||||
|
|
||||||
f
|
f
|
||||||
fs
|
fs
|
||||||
|
fv
|
||||||
fx
|
fx
|
||||||
id
|
id
|
||||||
PWD
|
PWD
|
||||||
@@ -238,6 +248,7 @@ The following special shell commands are used to customize the behavior of lf wh
|
|||||||
delete
|
delete
|
||||||
pre-cd
|
pre-cd
|
||||||
on-cd
|
on-cd
|
||||||
|
on-load
|
||||||
on-focus-gained
|
on-focus-gained
|
||||||
on-focus-lost
|
on-focus-lost
|
||||||
on-init
|
on-init
|
||||||
@@ -255,6 +266,8 @@ The following commands/keybindings are provided by default:
|
|||||||
cmd doc $$lf -doc | $PAGER
|
cmd doc $$lf -doc | $PAGER
|
||||||
map <f-1> doc
|
map <f-1> doc
|
||||||
cmd maps $lf -remote "query $id maps" | $PAGER
|
cmd maps $lf -remote "query $id maps" | $PAGER
|
||||||
|
cmd nmaps $lf -remote "query $id nmaps" | $PAGER
|
||||||
|
cmd vmaps $lf -remote "query $id vmaps" | $PAGER
|
||||||
cmd cmaps $lf -remote "query $id cmaps" | $PAGER
|
cmd cmaps $lf -remote "query $id cmaps" | $PAGER
|
||||||
cmd cmds $lf -remote "query $id cmds" | $PAGER
|
cmd cmds $lf -remote "query $id cmds" | $PAGER
|
||||||
|
|
||||||
@@ -266,6 +279,8 @@ The following commands/keybindings are provided by default:
|
|||||||
cmd doc !%lf% -doc | %PAGER%
|
cmd doc !%lf% -doc | %PAGER%
|
||||||
map <f-1> doc
|
map <f-1> doc
|
||||||
cmd maps !%lf% -remote "query %id% maps" | %PAGER%
|
cmd maps !%lf% -remote "query %id% maps" | %PAGER%
|
||||||
|
cmd nmaps !%lf% -remote "query %id% nmaps" | %PAGER%
|
||||||
|
cmd vmaps !%lf% -remote "query %id% vmaps" | %PAGER%
|
||||||
cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER%
|
cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER%
|
||||||
cmd cmds !%lf% -remote "query %id% cmds" | %PAGER%
|
cmd cmds !%lf% -remote "query %id% cmds" | %PAGER%
|
||||||
|
|
||||||
@@ -284,7 +299,7 @@ The following additional keybindings are provided by default:
|
|||||||
map sc :set sortby ctime; set info ctime
|
map sc :set sortby ctime; set info ctime
|
||||||
map se :set sortby ext; set info
|
map se :set sortby ext; set info
|
||||||
map gh cd ~
|
map gh cd ~
|
||||||
map <space> :toggle; down
|
nmap <space> :toggle; down
|
||||||
|
|
||||||
If the `mouse` option is enabled, mouse buttons have the following default effects:
|
If the `mouse` option is enabled, mouse buttons have the following default effects:
|
||||||
|
|
||||||
@@ -399,23 +414,33 @@ Move the current file selection to the high/middle/low of the screen.
|
|||||||
|
|
||||||
Toggle the selection of the current file or files given as arguments.
|
Toggle the selection of the current file or files given as arguments.
|
||||||
|
|
||||||
|
## visual (default `V`)
|
||||||
|
|
||||||
|
Switch to Visual mode.
|
||||||
|
If already in Visual mode, discard the visual selection and stay in Visual mode.
|
||||||
|
|
||||||
|
## visual-accept (default `V`)
|
||||||
|
|
||||||
|
Add the visual selection to the selection list, quit Visual mode and return to Normal mode.
|
||||||
|
|
||||||
|
## visual-unselect
|
||||||
|
|
||||||
|
Remove the visual selection from the selection list, quit Visual mode and return to Normal mode.
|
||||||
|
|
||||||
|
## visual-discard (default `<esc>`)
|
||||||
|
|
||||||
|
Discard the visual selection, quit Visual mode and return to Normal mode.
|
||||||
|
|
||||||
|
## visual-change (default `o`)
|
||||||
|
|
||||||
|
Go to the other end of the current Visual mode selection.
|
||||||
|
|
||||||
## invert (default `v`)
|
## invert (default `v`)
|
||||||
|
|
||||||
Reverse the selection of all files in the current directory (i.e. `toggle` all files).
|
Reverse the selection of all files in the current directory (i.e. `toggle` all files).
|
||||||
Selections in other directories are not affected by this command.
|
Selections in other directories are not affected by this command.
|
||||||
You can define a new command to select all files in the directory by combining `invert` with `unselect` (i.e. `cmd select-all :unselect; invert`), though this will also remove selections in other directories.
|
You can define a new command to select all files in the directory by combining `invert` with `unselect` (i.e. `cmd select-all :unselect; invert`), though this will also remove selections in other directories.
|
||||||
|
|
||||||
## invert-below
|
|
||||||
|
|
||||||
Reverse the selection (i.e. `toggle`) of all files at or after the current file in the current directory.
|
|
||||||
|
|
||||||
To select a contiguous block of files, use this command on the first file you want to select.
|
|
||||||
Then, move down to the first file you do *not* want to select (the one after the end of the desired selection) and use this command again.
|
|
||||||
This achieves an effect similar to the visual mode in Vim.
|
|
||||||
|
|
||||||
This command is experimental and may be removed once a better replacement for the visual mode is implemented in `lf`.
|
|
||||||
If you'd like to experiment with using this command, you should bind it to a key (e.g. `V`) for a better experience.
|
|
||||||
|
|
||||||
## unselect (default `u`)
|
## unselect (default `u`)
|
||||||
|
|
||||||
Remove the selection of all files in all directories.
|
Remove the selection of all files in all directories.
|
||||||
@@ -432,7 +457,7 @@ If the total size of a directory is not calculated, it will be shown as `-`.
|
|||||||
|
|
||||||
## clearmaps
|
## clearmaps
|
||||||
|
|
||||||
Remove all keybindings associated with the `map` command.
|
Remove all keybindings associated with the `map`, `nmap` and `vmap` command.
|
||||||
This command can be used in the config file to remove the default keybindings.
|
This command can be used in the config file to remove the default keybindings.
|
||||||
For safety purposes, `:` is left mapped to the `read` command, and `cmap` keybindings are retained so that it is still possible to exit `lf` using `:quit`.
|
For safety purposes, `:` is left mapped to the `read` command, and `cmap` keybindings are retained so that it is still possible to exit `lf` using `:quit`.
|
||||||
|
|
||||||
@@ -570,6 +595,12 @@ You can define a new tag-clearing command by combining `tag` with `tag-toggle` (
|
|||||||
|
|
||||||
Tag a file with `*` or a single width character given in the argument if the file is untagged, otherwise remove the tag.
|
Tag a file with `*` or a single width character given in the argument if the file is untagged, otherwise remove the tag.
|
||||||
|
|
||||||
|
## addcustominfo
|
||||||
|
|
||||||
|
Update the `custom` info field of the given file with the given string.
|
||||||
|
The info string may contain ANSI escape codes to further customize its appearance.
|
||||||
|
If no info is provided, clear the file's info instead.
|
||||||
|
|
||||||
## tty-write
|
## tty-write
|
||||||
|
|
||||||
Write the given string to the tty.
|
Write the given string to the tty.
|
||||||
@@ -578,7 +609,7 @@ Using `tty-write` is preferred over directly writing to `/dev/tty` because the l
|
|||||||
|
|
||||||
# COMMAND LINE COMMANDS
|
# COMMAND LINE COMMANDS
|
||||||
|
|
||||||
The prompt character specifies which of the several command-line modes you are in.
|
The prompt character specifies which of the several Command-line modes you are in.
|
||||||
For example, the `read` command takes you to the `:` mode.
|
For example, the `read` command takes you to the `:` mode.
|
||||||
|
|
||||||
When the cursor is at the first character in `:` mode, pressing one of the keys `!`, `$`, `%`, or `&` takes you to the corresponding mode.
|
When the cursor is at the first character in `:` mode, pressing one of the keys `!`, `$`, `%`, or `&` takes you to the corresponding mode.
|
||||||
@@ -589,7 +620,7 @@ A character refers to a Unicode code point, a word consists of letters and digit
|
|||||||
|
|
||||||
## cmd-escape (default `<esc>`)
|
## cmd-escape (default `<esc>`)
|
||||||
|
|
||||||
Quit command line mode and return to normal mode.
|
Quit Command-line mode and return to Normal mode.
|
||||||
|
|
||||||
## cmd-complete (default `<tab>`)
|
## cmd-complete (default `<tab>`)
|
||||||
|
|
||||||
@@ -611,7 +642,7 @@ Execute the current line.
|
|||||||
|
|
||||||
## cmd-interrupt (default `<c-c>`)
|
## cmd-interrupt (default `<c-c>`)
|
||||||
|
|
||||||
Interrupt the current shell-pipe command and return to the normal mode.
|
Interrupt the current shell-pipe command and return to the Normal mode.
|
||||||
|
|
||||||
## cmd-history-next (default `<c-n>` and `<down>`), cmd-history-prev (default `<c-p>` and `<up>`)
|
## cmd-history-next (default `<c-n>` and `<down>`), cmd-history-prev (default `<c-p>` and `<up>`)
|
||||||
|
|
||||||
@@ -632,7 +663,7 @@ Delete the next character.
|
|||||||
## cmd-delete-back (default `<backspace>` and `<backspace2>`)
|
## cmd-delete-back (default `<backspace>` and `<backspace2>`)
|
||||||
|
|
||||||
Delete the previous character.
|
Delete the previous character.
|
||||||
When at the beginning of a prompt, returns either to normal mode or to `:` mode.
|
When at the beginning of a prompt, returns either to Normal mode or to `:` mode.
|
||||||
|
|
||||||
## cmd-delete-home (default `<c-u>`), cmd-delete-end (default `<c-k>`)
|
## cmd-delete-home (default `<c-u>`), cmd-delete-end (default `<c-k>`)
|
||||||
|
|
||||||
@@ -755,7 +786,7 @@ For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`.
|
|||||||
|
|
||||||
## filesep (string) (default `\n`)
|
## filesep (string) (default `\n`)
|
||||||
|
|
||||||
File separator used in environment variables `fs` and `fx`.
|
File separator used in environment variables `fs`, `fv` and `fx`.
|
||||||
|
|
||||||
## findlen (int) (default 1)
|
## findlen (int) (default 1)
|
||||||
|
|
||||||
@@ -821,7 +852,8 @@ Apply filter pattern after each keystroke during filtering.
|
|||||||
## info ([]string) (default ``)
|
## info ([]string) (default ``)
|
||||||
|
|
||||||
A list of information that is shown for directory items at the right side of the pane.
|
A list of information that is shown for directory items at the right side of the pane.
|
||||||
Currently supported information types are `size`, `time`, `atime`, `ctime`, `perm`, `user` and `group`.
|
Currently supported information types are `size`, `time`, `atime`, `ctime`, `perm`, `user`, `group` and `custom`.
|
||||||
|
The `custom` type is empty by default and can be updated using the `addcustominfo` command.
|
||||||
Information is only shown when the pane width is more than twice the width of information.
|
Information is only shown when the pane width is more than twice the width of information.
|
||||||
|
|
||||||
## infotimefmtnew (string) (default `Jan _2 15:04`)
|
## infotimefmtnew (string) (default `Jan _2 15:04`)
|
||||||
@@ -907,10 +939,10 @@ Reverse the direction of sort.
|
|||||||
|
|
||||||
Draw rounded outer corners when the `drawbox` option is enabled.
|
Draw rounded outer corners when the `drawbox` option is enabled.
|
||||||
|
|
||||||
## rulerfmt (string) (default ` %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t`)
|
## rulerfmt (string) (default ` %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t`)
|
||||||
|
|
||||||
Format string of the ruler shown in the bottom right corner.
|
Format string of the ruler shown in the bottom right corner.
|
||||||
Special expansions are provided, `%a` as the pressed keys, `%p` as the progress of file operations, `%m` as the number of files to be cut (moved), `%c` as the number of files to be copied, `%s` as the number of selected files, `%f` as the filter, `%i` as the position of the cursor, `%t` as the number of files shown in the current directory, `%h` as the number of files hidden in the current directory, and `%d` as the amount of free disk space remaining.
|
Special expansions are provided, `%a` as the pressed keys, `%p` as the progress of file operations, `%m` as the number of files to be cut (moved), `%c` as the number of files to be copied, `%s` as the number of selected files, `%v` as the number of visually selected files, `%f` as the filter, `%i` as the position of the cursor, `%t` as the number of files shown in the current directory, `%h` as the number of files hidden in the current directory, `%P` as the scroll percentage, and `%d` as the amount of free disk space remaining.
|
||||||
Additional expansions are provided for environment variables exported by lf, in the form `%{lf_<name>}` (e.g. `%{lf_selmode}`). This is useful for displaying the current settings.
|
Additional expansions are provided for environment variables exported by lf, in the form `%{lf_<name>}` (e.g. `%{lf_selmode}`). This is useful for displaying the current settings.
|
||||||
Expansions are also provided for user-defined options, in the form `%{lf_user_<name>}` (e.g. `%{lf_user_foo}`).
|
Expansions are also provided for user-defined options, in the form `%{lf_user_<name>}` (e.g. `%{lf_user_foo}`).
|
||||||
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
|
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
|
||||||
@@ -965,12 +997,12 @@ This option has no effect when `ignoredia` is disabled.
|
|||||||
## sortby (string) (default `natural`)
|
## sortby (string) (default `natural`)
|
||||||
|
|
||||||
Sort type for directories.
|
Sort type for directories.
|
||||||
Currently supported sort types are `natural`, `name`, `size`, `time`, `ctime`, `atime`, and `ext`.
|
Currently supported sort types are `natural`, `name`, `size`, `time`, `ctime`, `atime`, `ext` and `custom`.
|
||||||
|
|
||||||
## statfmt (string) (default `\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l`)
|
## statfmt (string) (default `\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l`)
|
||||||
|
|
||||||
Format string of the file info shown in the bottom left corner.
|
Format string of the file info shown in the bottom left corner.
|
||||||
Special expansions are provided, `%p` as the file permissions, `%c` as the link count, `%u` as the user, `%g` as the group, `%s` as the file size, `%S` as the file size but with a fixed width of four characters (left-padded with spaces), `%t` as the last modified time, and `%l` as the link target.
|
Special expansions are provided, `%p` as the file permissions, `%c` as the link count, `%u` as the user, `%g` as the group, `%s` as the file size, `%S` as the file size but with a fixed width of four characters (left-padded with spaces), `%t` as the last modified time, `%l` as the link target, `%m` as the current mode and `%M` as the current mode but also shown in Normal mode (displaying `NORMAL` instead of a blank string).
|
||||||
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
|
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
|
||||||
|
|
||||||
## tabstop (int) (default 8)
|
## tabstop (int) (default 8)
|
||||||
@@ -1015,6 +1047,10 @@ while a value of 0 will only show the end of the filename, e.g.:
|
|||||||
|
|
||||||
- `set truncatepct 0` -> `~ng-filename-truncated`
|
- `set truncatepct 0` -> `~ng-filename-truncated`
|
||||||
|
|
||||||
|
## visualfmt (string) (default `\033[7;36m`)
|
||||||
|
|
||||||
|
Format string of the indicator for files that are visually selected.
|
||||||
|
|
||||||
## waitmsg (string) (default `Press any key to continue`)
|
## waitmsg (string) (default `Press any key to continue`)
|
||||||
|
|
||||||
String shown after commands of shell-wait type.
|
String shown after commands of shell-wait type.
|
||||||
@@ -1051,9 +1087,13 @@ Current file selection as a full path.
|
|||||||
|
|
||||||
Selected file(s) separated with the value of `filesep` option as full path(s).
|
Selected file(s) separated with the value of `filesep` option as full path(s).
|
||||||
|
|
||||||
|
## fv
|
||||||
|
|
||||||
|
Visually selected file(s) separated with the value of `filesep` option as full path(s).
|
||||||
|
|
||||||
## fx
|
## fx
|
||||||
|
|
||||||
Selected file(s) (i.e. `fs`) if there are any selected files, otherwise current file selection (i.e. `f`).
|
Selected file(s) (i.e. `fs`, never `fv`) if there are any selected files, otherwise current file selection (i.e. `f`).
|
||||||
|
|
||||||
## id
|
## id
|
||||||
|
|
||||||
@@ -1113,7 +1153,7 @@ Value of the count associated with the current command.
|
|||||||
|
|
||||||
Current mode that `lf` is operating in.
|
Current mode that `lf` is operating in.
|
||||||
This is useful for customizing keybindings depending on what the current mode is.
|
This is useful for customizing keybindings depending on what the current mode is.
|
||||||
Possible values are `delete`, `rename`, `filter`, `find`, `mark`, `search`, `command`, `shell`, `pipe` (when running a shell-pipe command), `normal`, and `unknown`.
|
Possible values are `delete`, `rename`, `filter`, `find`, `mark`, `search`, `command`, `shell`, `pipe` (when running a shell-pipe command), `normal`, `visual` and `unknown`.
|
||||||
|
|
||||||
# SPECIAL COMMANDS
|
# SPECIAL COMMANDS
|
||||||
|
|
||||||
@@ -1143,6 +1183,11 @@ This shell command can be defined to be executed before changing a directory.
|
|||||||
|
|
||||||
This shell command can be defined to be executed after changing a directory.
|
This shell command can be defined to be executed after changing a directory.
|
||||||
|
|
||||||
|
## on-load
|
||||||
|
|
||||||
|
This shell command can be defined to be executed after loading a directory.
|
||||||
|
It provides the files inside the directory as arguments.
|
||||||
|
|
||||||
## on-focus-gained
|
## on-focus-gained
|
||||||
|
|
||||||
This shell command can be defined to be executed when the terminal gains focus.
|
This shell command can be defined to be executed when the terminal gains focus.
|
||||||
@@ -1181,6 +1226,7 @@ The same evaluator is used for the command line and the configuration file for r
|
|||||||
The difference is that prefixes are not necessary in the command line.
|
The difference is that prefixes are not necessary in the command line.
|
||||||
Instead, different modes are provided to read corresponding commands.
|
Instead, different modes are provided to read corresponding commands.
|
||||||
These modes are mapped to the prefix keys above by default.
|
These modes are mapped to the prefix keys above by default.
|
||||||
|
Visual mode mappings are defined the same way Normal mode mappings are defined.
|
||||||
|
|
||||||
# SYNTAX
|
# SYNTAX
|
||||||
|
|
||||||
@@ -1188,7 +1234,7 @@ Characters from `#` to newline are comments and ignored:
|
|||||||
|
|
||||||
# comments start with `#`
|
# comments start with `#`
|
||||||
|
|
||||||
There are five special commands (`set`, `setlocal`, `map`, `cmap`, and `cmd`) for configuration.
|
The following commands (`set`, `setlocal`, `map`, `nmap`, `vmap`, `cmap`, and `cmd`) are used for configuration.
|
||||||
|
|
||||||
Command `set` is used to set an option which can be a boolean, integer, or string:
|
Command `set` is used to set an option which can be a boolean, integer, or string:
|
||||||
|
|
||||||
@@ -1217,21 +1263,34 @@ Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets th
|
|||||||
setlocal /foo/bar hidden # for only '/foo/bar' directory
|
setlocal /foo/bar hidden # for only '/foo/bar' directory
|
||||||
setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz')
|
setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz')
|
||||||
|
|
||||||
Command 'map' is used to bind a key to a command which can be a builtin command, custom command, or shell command:
|
Command `map` is used to bind a key in Normal and Visual mode to a command which can be a builtin command, custom command, or shell command:
|
||||||
|
|
||||||
map gh cd ~ # builtin command
|
map gh cd ~ # builtin command
|
||||||
map D trash # custom command
|
map D trash # custom command
|
||||||
map i $less $f # shell command
|
map i $less $f # shell command
|
||||||
map U !du -csh * # waiting shell command
|
map U !du -csh * # waiting shell command
|
||||||
|
|
||||||
Command 'cmap' is used to bind a key on the command line to a command line command or any other command:
|
Command `nmap` does the same but for Normal mode only.
|
||||||
|
|
||||||
|
Command `vmap` does the same but for Visual mode only.
|
||||||
|
|
||||||
|
Overview of which map command works in which mode:
|
||||||
|
|
||||||
|
map Normal, Visual
|
||||||
|
nmap Normal
|
||||||
|
vmap Visual
|
||||||
|
cmap Command-line
|
||||||
|
|
||||||
|
Command `cmap` is used to bind a key on the command line to a command line command or any other command:
|
||||||
|
|
||||||
cmap <c-g> cmd-escape
|
cmap <c-g> cmd-escape
|
||||||
cmap <a-i> set incsearch!
|
cmap <a-i> set incsearch!
|
||||||
|
|
||||||
You can delete an existing binding by leaving the expression empty:
|
You can delete an existing binding by leaving the expression empty:
|
||||||
|
|
||||||
map gh # deletes 'gh' mapping
|
map gh # deletes 'gh' mapping in normal and visual mode
|
||||||
|
nmap v # deletes 'v' mapping in normal mode
|
||||||
|
vmap o # deletes 'o' mapping in visual mode
|
||||||
cmap <c-g> # deletes '<c-g>' mapping
|
cmap <c-g> # deletes '<c-g>' mapping
|
||||||
|
|
||||||
Command `cmd` is used to define a custom command:
|
Command `cmd` is used to define a custom command:
|
||||||
@@ -1472,13 +1531,21 @@ In addition, the `query` command can be used to obtain information about a speci
|
|||||||
|
|
||||||
The following types of information are supported:
|
The following types of information are supported:
|
||||||
|
|
||||||
maps list of mappings created by the 'map' command
|
maps list of mappings created by the 'map', 'nmap' and 'vmap' command
|
||||||
|
nmaps list of mappings created by the 'nmap' and 'map' command
|
||||||
|
vmaps list of mappings created by the 'vmap' and 'map' command
|
||||||
cmaps list of mappings created by the 'cmap' command
|
cmaps list of mappings created by the 'cmap' command
|
||||||
cmds list of commands created by the 'cmd' command
|
cmds list of commands created by the 'cmd' command
|
||||||
jumps contents of the jump list, showing previously visited locations
|
jumps contents of the jump list, showing previously visited locations
|
||||||
history list of previously executed commands on the command line
|
history list of previously executed commands on the command line
|
||||||
files list of files in the currently open directory as displayed by lf, empty if dir is still loading
|
files list of files in the currently open directory as displayed by lf, empty if dir is still loading
|
||||||
|
|
||||||
|
When listing mappings the characters in the first column are:
|
||||||
|
|
||||||
|
n Normal
|
||||||
|
v Visual
|
||||||
|
c Command-line
|
||||||
|
|
||||||
This is useful for scripting actions based on the internal state of lf.
|
This is useful for scripting actions based on the internal state of lf.
|
||||||
For example, to select a previous command using fzf and execute it:
|
For example, to select a previous command using fzf and execute it:
|
||||||
|
|
||||||
@@ -1704,6 +1771,62 @@ You can add an extra call to make it run on startup as well:
|
|||||||
Note that all shell commands are possible but `%` and `&` are usually more appropriate as `$` and `!` causes flickers and pauses respectively.
|
Note that all shell commands are possible but `%` and `&` are usually more appropriate as `$` and `!` causes flickers and pauses respectively.
|
||||||
|
|
||||||
There is also a `pre-cd` command, that works like `on-cd`, but is run before the directory is actually changed.
|
There is also a `pre-cd` command, that works like `on-cd`, but is run before the directory is actually changed.
|
||||||
|
Another related command is `on-load` which gets executed when loading a directory.
|
||||||
|
|
||||||
|
# LOADING DIRECTORY
|
||||||
|
|
||||||
|
Similar to `on-cd` there also is `on-load` that when defined runs a shell command after loading a directory.
|
||||||
|
It works well when combined with `addcustominfo`.
|
||||||
|
|
||||||
|
The following example can be used to display git indicators in the info column:
|
||||||
|
|
||||||
|
cmd on-load &{{
|
||||||
|
cd "$(dirname "$1")" || exit 1
|
||||||
|
[ "$(git rev-parse --is-inside-git-dir 2>/dev/null)" = false ] || exit 0
|
||||||
|
|
||||||
|
cmds=""
|
||||||
|
|
||||||
|
for file in "$@"; do
|
||||||
|
case "$file" in
|
||||||
|
*/.git|*/.git/*) continue;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
status=$(git status --porcelain --ignored -- "$file" | cut -c1-2 | head -n1)
|
||||||
|
|
||||||
|
if [ -n "$status" ]; then
|
||||||
|
cmds="${cmds}addcustominfo \"${file}\" \"$status\"; "
|
||||||
|
else
|
||||||
|
cmds="${cmds}addcustominfo \"${file}\" ''; "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$cmds" ]; then
|
||||||
|
lf -remote "send $id :$cmds"
|
||||||
|
fi
|
||||||
|
}}
|
||||||
|
|
||||||
|
Another use case could be showing the dimensions of images and videos:
|
||||||
|
|
||||||
|
cmd on-load &{{
|
||||||
|
cmds=""
|
||||||
|
|
||||||
|
for file in "$@"; do
|
||||||
|
mime=$(file --mime-type -Lb -- "$file")
|
||||||
|
case "$mime" in
|
||||||
|
# vector images cause problems
|
||||||
|
image/svg+xml)
|
||||||
|
;;
|
||||||
|
image/*|video/*)
|
||||||
|
dimensions=$(exiftool -s3 -imagesize -- "$file")
|
||||||
|
cmds="${cmds}addcustominfo \"${file}\" \"$dimensions\"; "
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$cmds" ]; then
|
||||||
|
lf -remote "send $id :$cmds"
|
||||||
|
fi
|
||||||
|
}}
|
||||||
|
|
||||||
# COLORS
|
# COLORS
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ The following commands are provided by lf:
|
|||||||
middle (default 'M')
|
middle (default 'M')
|
||||||
low (default 'L')
|
low (default 'L')
|
||||||
toggle
|
toggle
|
||||||
|
visual (default 'V')
|
||||||
invert (default 'v')
|
invert (default 'v')
|
||||||
invert-below
|
|
||||||
unselect (default 'u')
|
unselect (default 'u')
|
||||||
glob-select
|
glob-select
|
||||||
glob-unselect
|
glob-unselect
|
||||||
@@ -92,9 +92,17 @@ The following commands are provided by lf:
|
|||||||
mark-remove (modal) (default '"')
|
mark-remove (modal) (default '"')
|
||||||
tag
|
tag
|
||||||
tag-toggle (default 't')
|
tag-toggle (default 't')
|
||||||
|
addcustominfo
|
||||||
tty-write
|
tty-write
|
||||||
|
|
||||||
The following command line commands are provided by lf:
|
The following Visual mode commands are provided by lf:
|
||||||
|
|
||||||
|
visual-accept (default 'V')
|
||||||
|
visual-unselect
|
||||||
|
visual-discard (default '<esc>')
|
||||||
|
visual-change (default 'o')
|
||||||
|
|
||||||
|
The following Command-line mode commands are provided by lf:
|
||||||
|
|
||||||
cmd-escape (default '<esc>')
|
cmd-escape (default '<esc>')
|
||||||
cmd-complete (default '<tab>')
|
cmd-complete (default '<tab>')
|
||||||
@@ -192,6 +200,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
truncatechar string (default '~')
|
truncatechar string (default '~')
|
||||||
truncatepct int (default 100)
|
truncatepct int (default 100)
|
||||||
|
visualfmt string (default "\033[7;36m")
|
||||||
waitmsg string (default 'Press any key to continue')
|
waitmsg string (default 'Press any key to continue')
|
||||||
watch bool (default false)
|
watch bool (default false)
|
||||||
wrapscan bool (default true)
|
wrapscan bool (default true)
|
||||||
@@ -202,6 +211,7 @@ The following environment variables are exported for shell commands:
|
|||||||
|
|
||||||
f
|
f
|
||||||
fs
|
fs
|
||||||
|
fv
|
||||||
fx
|
fx
|
||||||
id
|
id
|
||||||
PWD
|
PWD
|
||||||
@@ -229,6 +239,7 @@ of lf when defined:
|
|||||||
delete
|
delete
|
||||||
pre-cd
|
pre-cd
|
||||||
on-cd
|
on-cd
|
||||||
|
on-load
|
||||||
on-focus-gained
|
on-focus-gained
|
||||||
on-focus-lost
|
on-focus-lost
|
||||||
on-init
|
on-init
|
||||||
@@ -246,6 +257,8 @@ The following commands/keybindings are provided by default:
|
|||||||
cmd doc $$lf -doc | $PAGER
|
cmd doc $$lf -doc | $PAGER
|
||||||
map <f-1> doc
|
map <f-1> doc
|
||||||
cmd maps $lf -remote "query $id maps" | $PAGER
|
cmd maps $lf -remote "query $id maps" | $PAGER
|
||||||
|
cmd nmaps $lf -remote "query $id nmaps" | $PAGER
|
||||||
|
cmd vmaps $lf -remote "query $id vmaps" | $PAGER
|
||||||
cmd cmaps $lf -remote "query $id cmaps" | $PAGER
|
cmd cmaps $lf -remote "query $id cmaps" | $PAGER
|
||||||
cmd cmds $lf -remote "query $id cmds" | $PAGER
|
cmd cmds $lf -remote "query $id cmds" | $PAGER
|
||||||
|
|
||||||
@@ -257,6 +270,8 @@ The following commands/keybindings are provided by default:
|
|||||||
cmd doc !%lf% -doc | %PAGER%
|
cmd doc !%lf% -doc | %PAGER%
|
||||||
map <f-1> doc
|
map <f-1> doc
|
||||||
cmd maps !%lf% -remote "query %id% maps" | %PAGER%
|
cmd maps !%lf% -remote "query %id% maps" | %PAGER%
|
||||||
|
cmd nmaps !%lf% -remote "query %id% nmaps" | %PAGER%
|
||||||
|
cmd vmaps !%lf% -remote "query %id% vmaps" | %PAGER%
|
||||||
cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER%
|
cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER%
|
||||||
cmd cmds !%lf% -remote "query %id% cmds" | %PAGER%
|
cmd cmds !%lf% -remote "query %id% cmds" | %PAGER%
|
||||||
|
|
||||||
@@ -275,7 +290,7 @@ The following additional keybindings are provided by default:
|
|||||||
map sc :set sortby ctime; set info ctime
|
map sc :set sortby ctime; set info ctime
|
||||||
map se :set sortby ext; set info
|
map se :set sortby ext; set info
|
||||||
map gh cd ~
|
map gh cd ~
|
||||||
map <space> :toggle; down
|
nmap <space> :toggle; down
|
||||||
|
|
||||||
If the mouse option is enabled, mouse buttons have the following default
|
If the mouse option is enabled, mouse buttons have the following default
|
||||||
effects:
|
effects:
|
||||||
@@ -398,6 +413,30 @@ toggle
|
|||||||
|
|
||||||
Toggle the selection of the current file or files given as arguments.
|
Toggle the selection of the current file or files given as arguments.
|
||||||
|
|
||||||
|
visual (default V)
|
||||||
|
|
||||||
|
Switch to Visual mode. If already in Visual mode, discard the visual
|
||||||
|
selection and stay in Visual mode.
|
||||||
|
|
||||||
|
visual-accept (default V)
|
||||||
|
|
||||||
|
Add the visual selection to the selection list, quit Visual mode and
|
||||||
|
return to Normal mode.
|
||||||
|
|
||||||
|
visual-unselect
|
||||||
|
|
||||||
|
Remove the visual selection from the selection list, quit Visual mode
|
||||||
|
and return to Normal mode.
|
||||||
|
|
||||||
|
visual-discard (default <esc>)
|
||||||
|
|
||||||
|
Discard the visual selection, quit Visual mode and return to Normal
|
||||||
|
mode.
|
||||||
|
|
||||||
|
visual-change (default o)
|
||||||
|
|
||||||
|
Go to the other end of the current Visual mode selection.
|
||||||
|
|
||||||
invert (default v)
|
invert (default v)
|
||||||
|
|
||||||
Reverse the selection of all files in the current directory (i.e. toggle
|
Reverse the selection of all files in the current directory (i.e. toggle
|
||||||
@@ -407,22 +446,6 @@ directory by combining invert with unselect (i.e.
|
|||||||
cmd select-all :unselect; invert), though this will also remove
|
cmd select-all :unselect; invert), though this will also remove
|
||||||
selections in other directories.
|
selections in other directories.
|
||||||
|
|
||||||
invert-below
|
|
||||||
|
|
||||||
Reverse the selection (i.e. toggle) of all files at or after the current
|
|
||||||
file in the current directory.
|
|
||||||
|
|
||||||
To select a contiguous block of files, use this command on the first
|
|
||||||
file you want to select. Then, move down to the first file you do not
|
|
||||||
want to select (the one after the end of the desired selection) and use
|
|
||||||
this command again. This achieves an effect similar to the visual mode
|
|
||||||
in Vim.
|
|
||||||
|
|
||||||
This command is experimental and may be removed once a better
|
|
||||||
replacement for the visual mode is implemented in lf. If you'd like to
|
|
||||||
experiment with using this command, you should bind it to a key (e.g. V)
|
|
||||||
for a better experience.
|
|
||||||
|
|
||||||
unselect (default u)
|
unselect (default u)
|
||||||
|
|
||||||
Remove the selection of all files in all directories.
|
Remove the selection of all files in all directories.
|
||||||
@@ -440,10 +463,11 @@ be shown as -.
|
|||||||
|
|
||||||
clearmaps
|
clearmaps
|
||||||
|
|
||||||
Remove all keybindings associated with the map command. This command can
|
Remove all keybindings associated with the map, nmap and vmap command.
|
||||||
be used in the config file to remove the default keybindings. For safety
|
This command can be used in the config file to remove the default
|
||||||
purposes, : is left mapped to the read command, and cmap keybindings are
|
keybindings. For safety purposes, : is left mapped to the read command,
|
||||||
retained so that it is still possible to exit lf using :quit.
|
and cmap keybindings are retained so that it is still possible to exit
|
||||||
|
lf using :quit.
|
||||||
|
|
||||||
copy (default y)
|
copy (default y)
|
||||||
|
|
||||||
@@ -589,6 +613,12 @@ tag-toggle (default t)
|
|||||||
Tag a file with * or a single width character given in the argument if
|
Tag a file with * or a single width character given in the argument if
|
||||||
the file is untagged, otherwise remove the tag.
|
the file is untagged, otherwise remove the tag.
|
||||||
|
|
||||||
|
addcustominfo
|
||||||
|
|
||||||
|
Update the custom info field of the given file with the given string.
|
||||||
|
The info string may contain ANSI escape codes to further customize its
|
||||||
|
appearance. If no info is provided, clear the file's info instead.
|
||||||
|
|
||||||
tty-write
|
tty-write
|
||||||
|
|
||||||
Write the given string to the tty. This is useful for sending escape
|
Write the given string to the tty. This is useful for sending escape
|
||||||
@@ -599,7 +629,7 @@ drawing the UI.
|
|||||||
|
|
||||||
COMMAND LINE COMMANDS
|
COMMAND LINE COMMANDS
|
||||||
|
|
||||||
The prompt character specifies which of the several command-line modes
|
The prompt character specifies which of the several Command-line modes
|
||||||
you are in. For example, the read command takes you to the : mode.
|
you are in. For example, the read command takes you to the : mode.
|
||||||
|
|
||||||
When the cursor is at the first character in : mode, pressing one of the
|
When the cursor is at the first character in : mode, pressing one of the
|
||||||
@@ -613,7 +643,7 @@ characters.
|
|||||||
|
|
||||||
cmd-escape (default <esc>)
|
cmd-escape (default <esc>)
|
||||||
|
|
||||||
Quit command line mode and return to normal mode.
|
Quit Command-line mode and return to Normal mode.
|
||||||
|
|
||||||
cmd-complete (default <tab>)
|
cmd-complete (default <tab>)
|
||||||
|
|
||||||
@@ -638,7 +668,7 @@ Execute the current line.
|
|||||||
|
|
||||||
cmd-interrupt (default <c-c>)
|
cmd-interrupt (default <c-c>)
|
||||||
|
|
||||||
Interrupt the current shell-pipe command and return to the normal mode.
|
Interrupt the current shell-pipe command and return to the Normal mode.
|
||||||
|
|
||||||
cmd-history-next (default <c-n> and <down>), cmd-history-prev (default <c-p> and <up>)
|
cmd-history-next (default <c-n> and <down>), cmd-history-prev (default <c-p> and <up>)
|
||||||
|
|
||||||
@@ -659,7 +689,7 @@ Delete the next character.
|
|||||||
cmd-delete-back (default <backspace> and <backspace2>)
|
cmd-delete-back (default <backspace> and <backspace2>)
|
||||||
|
|
||||||
Delete the previous character. When at the beginning of a prompt,
|
Delete the previous character. When at the beginning of a prompt,
|
||||||
returns either to normal mode or to : mode.
|
returns either to Normal mode or to : mode.
|
||||||
|
|
||||||
cmd-delete-home (default <c-u>), cmd-delete-end (default <c-k>)
|
cmd-delete-home (default <c-u>), cmd-delete-end (default <c-k>)
|
||||||
|
|
||||||
@@ -805,7 +835,7 @@ effect as \033[4m.
|
|||||||
|
|
||||||
filesep (string) (default \n)
|
filesep (string) (default \n)
|
||||||
|
|
||||||
File separator used in environment variables fs and fx.
|
File separator used in environment variables fs, fv and fx.
|
||||||
|
|
||||||
findlen (int) (default 1)
|
findlen (int) (default 1)
|
||||||
|
|
||||||
@@ -876,8 +906,10 @@ info ([]string) (default ``)
|
|||||||
|
|
||||||
A list of information that is shown for directory items at the right
|
A list of information that is shown for directory items at the right
|
||||||
side of the pane. Currently supported information types are size, time,
|
side of the pane. Currently supported information types are size, time,
|
||||||
atime, ctime, perm, user and group. Information is only shown when the
|
atime, ctime, perm, user, group and custom. The custom type is empty by
|
||||||
pane width is more than twice the width of information.
|
default and can be updated using the addcustominfo command. Information
|
||||||
|
is only shown when the pane width is more than twice the width of
|
||||||
|
information.
|
||||||
|
|
||||||
infotimefmtnew (string) (default Jan _2 15:04)
|
infotimefmtnew (string) (default Jan _2 15:04)
|
||||||
|
|
||||||
@@ -981,19 +1013,20 @@ roundbox (bool) (default false)
|
|||||||
|
|
||||||
Draw rounded outer corners when the drawbox option is enabled.
|
Draw rounded outer corners when the drawbox option is enabled.
|
||||||
|
|
||||||
rulerfmt (string) (default %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t)
|
rulerfmt (string) (default %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t)
|
||||||
|
|
||||||
Format string of the ruler shown in the bottom right corner. Special
|
Format string of the ruler shown in the bottom right corner. Special
|
||||||
expansions are provided, %a as the pressed keys, %p as the progress of
|
expansions are provided, %a as the pressed keys, %p as the progress of
|
||||||
file operations, %m as the number of files to be cut (moved), %c as the
|
file operations, %m as the number of files to be cut (moved), %c as the
|
||||||
number of files to be copied, %s as the number of selected files, %f as
|
number of files to be copied, %s as the number of selected files, %v as
|
||||||
the filter, %i as the position of the cursor, %t as the number of files
|
the number of visually selected files, %f as the filter, %i as the
|
||||||
shown in the current directory, %h as the number of files hidden in the
|
position of the cursor, %t as the number of files shown in the current
|
||||||
current directory, and %d as the amount of free disk space remaining.
|
directory, %h as the number of files hidden in the current directory, %P
|
||||||
Additional expansions are provided for environment variables exported by
|
as the scroll percentage, and %d as the amount of free disk space
|
||||||
lf, in the form %{lf_<name>} (e.g. %{lf_selmode}). This is useful for
|
remaining. Additional expansions are provided for environment variables
|
||||||
displaying the current settings. Expansions are also provided for
|
exported by lf, in the form %{lf_<name>} (e.g. %{lf_selmode}). This is
|
||||||
user-defined options, in the form %{lf_user_<name>} (e.g.
|
useful for displaying the current settings. Expansions are also provided
|
||||||
|
for user-defined options, in the form %{lf_user_<name>} (e.g.
|
||||||
%{lf_user_foo}). The | character splits the format string into sections.
|
%{lf_user_foo}). The | character splits the format string into sections.
|
||||||
Any section containing a failed expansion (result is a blank string) is
|
Any section containing a failed expansion (result is a blank string) is
|
||||||
discarded and not shown.
|
discarded and not shown.
|
||||||
@@ -1051,7 +1084,7 @@ diacritic. This option has no effect when ignoredia is disabled.
|
|||||||
sortby (string) (default natural)
|
sortby (string) (default natural)
|
||||||
|
|
||||||
Sort type for directories. Currently supported sort types are natural,
|
Sort type for directories. Currently supported sort types are natural,
|
||||||
name, size, time, ctime, atime, and ext.
|
name, size, time, ctime, atime, ext and custom.
|
||||||
|
|
||||||
statfmt (string) (default \033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l)
|
statfmt (string) (default \033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l)
|
||||||
|
|
||||||
@@ -1059,10 +1092,11 @@ Format string of the file info shown in the bottom left corner. Special
|
|||||||
expansions are provided, %p as the file permissions, %c as the link
|
expansions are provided, %p as the file permissions, %c as the link
|
||||||
count, %u as the user, %g as the group, %s as the file size, %S as the
|
count, %u as the user, %g as the group, %s as the file size, %S as the
|
||||||
file size but with a fixed width of four characters (left-padded with
|
file size but with a fixed width of four characters (left-padded with
|
||||||
spaces), %t as the last modified time, and %l as the link target. The |
|
spaces), %t as the last modified time, %l as the link target, %m as the
|
||||||
character splits the format string into sections. Any section containing
|
current mode and %M as the current mode but also shown in Normal mode
|
||||||
a failed expansion (result is a blank string) is discarded and not
|
(displaying NORMAL instead of a blank string). The | character splits
|
||||||
shown.
|
the format string into sections. Any section containing a failed
|
||||||
|
expansion (result is a blank string) is discarded and not shown.
|
||||||
|
|
||||||
tabstop (int) (default 8)
|
tabstop (int) (default 8)
|
||||||
|
|
||||||
@@ -1111,6 +1145,10 @@ will only show the end of the filename, e.g.:
|
|||||||
|
|
||||||
- set truncatepct 0 -> ~ng-filename-truncated
|
- set truncatepct 0 -> ~ng-filename-truncated
|
||||||
|
|
||||||
|
visualfmt (string) (default \033[7;36m)
|
||||||
|
|
||||||
|
Format string of the indicator for files that are visually selected.
|
||||||
|
|
||||||
waitmsg (string) (default Press any key to continue)
|
waitmsg (string) (default Press any key to continue)
|
||||||
|
|
||||||
String shown after commands of shell-wait type.
|
String shown after commands of shell-wait type.
|
||||||
@@ -1152,10 +1190,15 @@ fs
|
|||||||
Selected file(s) separated with the value of filesep option as full
|
Selected file(s) separated with the value of filesep option as full
|
||||||
path(s).
|
path(s).
|
||||||
|
|
||||||
|
fv
|
||||||
|
|
||||||
|
Visually selected file(s) separated with the value of filesep option as
|
||||||
|
full path(s).
|
||||||
|
|
||||||
fx
|
fx
|
||||||
|
|
||||||
Selected file(s) (i.e. fs) if there are any selected files, otherwise
|
Selected file(s) (i.e. fs, never fv) if there are any selected files,
|
||||||
current file selection (i.e. f).
|
otherwise current file selection (i.e. f).
|
||||||
|
|
||||||
id
|
id
|
||||||
|
|
||||||
@@ -1226,7 +1269,7 @@ lf_mode
|
|||||||
Current mode that lf is operating in. This is useful for customizing
|
Current mode that lf is operating in. This is useful for customizing
|
||||||
keybindings depending on what the current mode is. Possible values are
|
keybindings depending on what the current mode is. Possible values are
|
||||||
delete, rename, filter, find, mark, search, command, shell, pipe (when
|
delete, rename, filter, find, mark, search, command, shell, pipe (when
|
||||||
running a shell-pipe command), normal, and unknown.
|
running a shell-pipe command), normal, visual and unknown.
|
||||||
|
|
||||||
SPECIAL COMMANDS
|
SPECIAL COMMANDS
|
||||||
|
|
||||||
@@ -1261,6 +1304,11 @@ on-cd
|
|||||||
This shell command can be defined to be executed after changing a
|
This shell command can be defined to be executed after changing a
|
||||||
directory.
|
directory.
|
||||||
|
|
||||||
|
on-load
|
||||||
|
|
||||||
|
This shell command can be defined to be executed after loading a
|
||||||
|
directory. It provides the files inside the directory as arguments.
|
||||||
|
|
||||||
on-focus-gained
|
on-focus-gained
|
||||||
|
|
||||||
This shell command can be defined to be executed when the terminal gains
|
This shell command can be defined to be executed when the terminal gains
|
||||||
@@ -1304,7 +1352,8 @@ The same evaluator is used for the command line and the configuration
|
|||||||
file for reading shell commands. The difference is that prefixes are not
|
file for reading shell commands. The difference is that prefixes are not
|
||||||
necessary in the command line. Instead, different modes are provided to
|
necessary in the command line. Instead, different modes are provided to
|
||||||
read corresponding commands. These modes are mapped to the prefix keys
|
read corresponding commands. These modes are mapped to the prefix keys
|
||||||
above by default.
|
above by default. Visual mode mappings are defined the same way Normal
|
||||||
|
mode mappings are defined.
|
||||||
|
|
||||||
SYNTAX
|
SYNTAX
|
||||||
|
|
||||||
@@ -1312,8 +1361,8 @@ Characters from # to newline are comments and ignored:
|
|||||||
|
|
||||||
# comments start with `#`
|
# comments start with `#`
|
||||||
|
|
||||||
There are five special commands (set, setlocal, map, cmap, and cmd) for
|
The following commands (set, setlocal, map, nmap, vmap, cmap, and cmd)
|
||||||
configuration.
|
are used for configuration.
|
||||||
|
|
||||||
Command set is used to set an option which can be a boolean, integer, or
|
Command set is used to set an option which can be a boolean, integer, or
|
||||||
string:
|
string:
|
||||||
@@ -1345,23 +1394,36 @@ option for the given directory along with its subdirectories:
|
|||||||
setlocal /foo/bar hidden # for only '/foo/bar' directory
|
setlocal /foo/bar hidden # for only '/foo/bar' directory
|
||||||
setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz')
|
setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz')
|
||||||
|
|
||||||
Command 'map' is used to bind a key to a command which can be a builtin
|
Command map is used to bind a key in Normal and Visual mode to a command
|
||||||
command, custom command, or shell command:
|
which can be a builtin command, custom command, or shell command:
|
||||||
|
|
||||||
map gh cd ~ # builtin command
|
map gh cd ~ # builtin command
|
||||||
map D trash # custom command
|
map D trash # custom command
|
||||||
map i $less $f # shell command
|
map i $less $f # shell command
|
||||||
map U !du -csh * # waiting shell command
|
map U !du -csh * # waiting shell command
|
||||||
|
|
||||||
Command 'cmap' is used to bind a key on the command line to a command
|
Command nmap does the same but for Normal mode only.
|
||||||
line command or any other command:
|
|
||||||
|
Command vmap does the same but for Visual mode only.
|
||||||
|
|
||||||
|
Overview of which map command works in which mode:
|
||||||
|
|
||||||
|
map Normal, Visual
|
||||||
|
nmap Normal
|
||||||
|
vmap Visual
|
||||||
|
cmap Command-line
|
||||||
|
|
||||||
|
Command cmap is used to bind a key on the command line to a command line
|
||||||
|
command or any other command:
|
||||||
|
|
||||||
cmap <c-g> cmd-escape
|
cmap <c-g> cmd-escape
|
||||||
cmap <a-i> set incsearch!
|
cmap <a-i> set incsearch!
|
||||||
|
|
||||||
You can delete an existing binding by leaving the expression empty:
|
You can delete an existing binding by leaving the expression empty:
|
||||||
|
|
||||||
map gh # deletes 'gh' mapping
|
map gh # deletes 'gh' mapping in normal and visual mode
|
||||||
|
nmap v # deletes 'v' mapping in normal mode
|
||||||
|
vmap o # deletes 'o' mapping in visual mode
|
||||||
cmap <c-g> # deletes '<c-g>' mapping
|
cmap <c-g> # deletes '<c-g>' mapping
|
||||||
|
|
||||||
Command cmd is used to define a custom command:
|
Command cmd is used to define a custom command:
|
||||||
@@ -1638,13 +1700,21 @@ specific lf instance by providing its id:
|
|||||||
|
|
||||||
The following types of information are supported:
|
The following types of information are supported:
|
||||||
|
|
||||||
maps list of mappings created by the 'map' command
|
maps list of mappings created by the 'map', 'nmap' and 'vmap' command
|
||||||
|
nmaps list of mappings created by the 'nmap' and 'map' command
|
||||||
|
vmaps list of mappings created by the 'vmap' and 'map' command
|
||||||
cmaps list of mappings created by the 'cmap' command
|
cmaps list of mappings created by the 'cmap' command
|
||||||
cmds list of commands created by the 'cmd' command
|
cmds list of commands created by the 'cmd' command
|
||||||
jumps contents of the jump list, showing previously visited locations
|
jumps contents of the jump list, showing previously visited locations
|
||||||
history list of previously executed commands on the command line
|
history list of previously executed commands on the command line
|
||||||
files list of files in the currently open directory as displayed by lf, empty if dir is still loading
|
files list of files in the currently open directory as displayed by lf, empty if dir is still loading
|
||||||
|
|
||||||
|
When listing mappings the characters in the first column are:
|
||||||
|
|
||||||
|
n Normal
|
||||||
|
v Visual
|
||||||
|
c Command-line
|
||||||
|
|
||||||
This is useful for scripting actions based on the internal state of lf.
|
This is useful for scripting actions based on the internal state of lf.
|
||||||
For example, to select a previous command using fzf and execute it:
|
For example, to select a previous command using fzf and execute it:
|
||||||
|
|
||||||
@@ -1920,7 +1990,65 @@ Note that all shell commands are possible but % and & are usually more
|
|||||||
appropriate as $ and ! causes flickers and pauses respectively.
|
appropriate as $ and ! causes flickers and pauses respectively.
|
||||||
|
|
||||||
There is also a pre-cd command, that works like on-cd, but is run before
|
There is also a pre-cd command, that works like on-cd, but is run before
|
||||||
the directory is actually changed.
|
the directory is actually changed. Another related command is on-load
|
||||||
|
which gets executed when loading a directory.
|
||||||
|
|
||||||
|
LOADING DIRECTORY
|
||||||
|
|
||||||
|
Similar to on-cd there also is on-load that when defined runs a shell
|
||||||
|
command after loading a directory. It works well when combined with
|
||||||
|
addcustominfo.
|
||||||
|
|
||||||
|
The following example can be used to display git indicators in the info
|
||||||
|
column:
|
||||||
|
|
||||||
|
cmd on-load &{{
|
||||||
|
cd "$(dirname "$1")" || exit 1
|
||||||
|
[ "$(git rev-parse --is-inside-git-dir 2>/dev/null)" = false ] || exit 0
|
||||||
|
|
||||||
|
cmds=""
|
||||||
|
|
||||||
|
for file in "$@"; do
|
||||||
|
case "$file" in
|
||||||
|
*/.git|*/.git/*) continue;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
status=$(git status --porcelain --ignored -- "$file" | cut -c1-2 | head -n1)
|
||||||
|
|
||||||
|
if [ -n "$status" ]; then
|
||||||
|
cmds="${cmds}addcustominfo \"${file}\" \"$status\"; "
|
||||||
|
else
|
||||||
|
cmds="${cmds}addcustominfo \"${file}\" ''; "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$cmds" ]; then
|
||||||
|
lf -remote "send $id :$cmds"
|
||||||
|
fi
|
||||||
|
}}
|
||||||
|
|
||||||
|
Another use case could be showing the dimensions of images and videos:
|
||||||
|
|
||||||
|
cmd on-load &{{
|
||||||
|
cmds=""
|
||||||
|
|
||||||
|
for file in "$@"; do
|
||||||
|
mime=$(file --mime-type -Lb -- "$file")
|
||||||
|
case "$mime" in
|
||||||
|
# vector images cause problems
|
||||||
|
image/svg+xml)
|
||||||
|
;;
|
||||||
|
image/*|video/*)
|
||||||
|
dimensions=$(exiftool -s3 -imagesize -- "$file")
|
||||||
|
cmds="${cmds}addcustominfo \"${file}\" \"$dimensions\"; "
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$cmds" ]; then
|
||||||
|
lf -remote "send $id :$cmds"
|
||||||
|
fi
|
||||||
|
}}
|
||||||
|
|
||||||
COLORS
|
COLORS
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# Change working dir in shell to last dir in lf on exit (adapted from ranger).
|
# Change working dir in shell to last dir in lf on exit (adapted from ranger).
|
||||||
#
|
#
|
||||||
# You need to add this to your Nushell Enviroment Config File
|
# You need to add this to your Nushell Environment Config File
|
||||||
# (Execute 'config env' in the nushell to open it).
|
# (Execute 'config env' in the nushell to open it).
|
||||||
|
|
||||||
# You may also like to assign a key (Ctrl-O) to this command:
|
# You may also like to assign a key (Ctrl-O) to this command:
|
||||||
|
|||||||
+23
-32
@@ -1,39 +1,30 @@
|
|||||||
# interpreter for shell commands
|
# interpreter for shell commands
|
||||||
set shell powershell
|
set shell pwsh
|
||||||
|
|
||||||
|
# allow the usage of $args inside shell commands
|
||||||
|
set shellflag "-cwa"
|
||||||
|
|
||||||
|
# speed up Powershell by skipping the profile
|
||||||
|
set shellopts "-nop"
|
||||||
|
|
||||||
# Shell commands with multiline definitions and/or positional arguments and/or
|
# Shell commands with multiline definitions and/or positional arguments and/or
|
||||||
# quotes do not work in Windows. For anything but the simplest shell commands,
|
# quotes only partly work in Windows. For anything but the simplest shell commands,
|
||||||
# it is recommended to create separate script files and simply call them here
|
# it is recommended to create separate script files and simply call them here
|
||||||
# in commands or mappings.
|
# in commands or mappings.
|
||||||
#
|
#
|
||||||
# Also, the default keybindings are defined using cmd syntax (i.e. '%EDITOR%')
|
# Also, the default commands and keybindings are defined using cmd syntax (i.e. '%EDITOR%')
|
||||||
# which does not work with powershell. Therefore, you need to override these
|
# which does not work with Powershell. Therefore, you need to override these
|
||||||
# keybindings with explicit choices accordingly.
|
# with explicit choices accordingly.
|
||||||
|
|
||||||
# change the default open command to work in powerShell
|
# change the default commands and keybindings to work in Powershell
|
||||||
cmd open &start $Env:f
|
cmd open &&$Env:OPENER.Trim('"', ' ') "$Env:f"
|
||||||
|
map e $&$Env:EDITOR "$Env:f"
|
||||||
# change the editor used in default editor keybinding
|
map i !&$Env:PAGER "$Env:f"
|
||||||
# There is no builtin terminal editor installed in Windows. The default editor
|
map w $&$Env:SHELL
|
||||||
# mapping uses 'notepad' which launches in a separate GUI window. You may
|
cmd doc !&$Env:lf -doc | &$Env:PAGER
|
||||||
# instead install a terminal editor of your choice and replace the default
|
map <f-1> doc
|
||||||
# editor keybinding accordingly.
|
cmd maps !&$Env:lf -remote "query $Env:id maps" | &$Env:PAGER
|
||||||
map e $vim $Env:f
|
cmd nmaps !&$Env:lf -remote "query $Env:id nmaps" | &$Env:PAGER
|
||||||
|
cmd vmaps !&$Env:lf -remote "query $Env:id vmaps" | &$Env:PAGER
|
||||||
# change the pager used in default pager keybinding
|
cmd cmaps !&$Env:lf -remote "query $Env:id cmaps" | &$Env:PAGER
|
||||||
# The standard pager used in Windows is 'more' which is not a very capable
|
cmd cmds !&$Env:lf -remote "query $Env:id cmds" | &$Env:PAGER
|
||||||
# pager. You may instead install a pager of your choice and replace the default
|
|
||||||
# pager keybinding accordingly.
|
|
||||||
map i $less $Env:f
|
|
||||||
|
|
||||||
# change the shell used in default shell keybinding
|
|
||||||
map w $powershell
|
|
||||||
|
|
||||||
# change 'doc' command to use a different pager
|
|
||||||
cmd doc $lf -doc | less
|
|
||||||
|
|
||||||
# leave some space at the top and the bottom of the screen
|
|
||||||
set scrolloff 10
|
|
||||||
|
|
||||||
# use enter for shell commands
|
|
||||||
map <enter> shell
|
|
||||||
@@ -91,9 +91,6 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
if app.nav.height != app.ui.wins[0].h {
|
if app.nav.height != app.ui.wins[0].h {
|
||||||
app.nav.height = app.ui.wins[0].h
|
app.nav.height = app.ui.wins[0].h
|
||||||
clear(app.nav.regCache)
|
clear(app.nav.regCache)
|
||||||
if gOpts.sixel {
|
|
||||||
app.ui.sxScreen.lastFile = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
}
|
}
|
||||||
@@ -157,6 +154,9 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
err = errors.New("preview: 'ratios' should consist of at least two numbers before enabling 'preview'")
|
err = errors.New("preview: 'ratios' should consist of at least two numbers before enabling 'preview'")
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if gOpts.sixel {
|
||||||
|
app.ui.sxScreen.forceClear = true
|
||||||
|
}
|
||||||
gOpts.preview = preview
|
gOpts.preview = preview
|
||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
}
|
}
|
||||||
@@ -174,6 +174,9 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
err = applyBoolOpt(&gOpts.showbinds, e)
|
err = applyBoolOpt(&gOpts.showbinds, e)
|
||||||
case "sixel", "nosixel", "sixel!":
|
case "sixel", "nosixel", "sixel!":
|
||||||
err = applyBoolOpt(&gOpts.sixel, e)
|
err = applyBoolOpt(&gOpts.sixel, e)
|
||||||
|
clear(app.nav.regCache)
|
||||||
|
app.ui.sxScreen.forceClear = true
|
||||||
|
app.ui.loadFile(app, true)
|
||||||
case "smartcase", "nosmartcase", "smartcase!":
|
case "smartcase", "nosmartcase", "smartcase!":
|
||||||
err = applyBoolOpt(&gOpts.smartcase, e)
|
err = applyBoolOpt(&gOpts.smartcase, e)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -265,9 +268,9 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
toks := strings.Split(e.val, ":")
|
toks := strings.Split(e.val, ":")
|
||||||
for _, s := range toks {
|
for _, s := range toks {
|
||||||
switch s {
|
switch s {
|
||||||
case "size", "time", "atime", "ctime", "perm", "user", "group":
|
case "size", "time", "atime", "ctime", "perm", "user", "group", "custom":
|
||||||
default:
|
default:
|
||||||
app.ui.echoerr("info: should consist of 'size', 'time', 'atime', 'ctime', 'perm', 'user' or 'group' separated with colon")
|
app.ui.echoerr("info: should consist of 'size', 'time', 'atime', 'ctime', 'perm', 'user', 'group' or 'custom' separated with colon")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -350,7 +353,6 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
app.ui.wins = getWins(app.ui.screen)
|
app.ui.wins = getWins(app.ui.screen)
|
||||||
if gOpts.sixel {
|
if gOpts.sixel {
|
||||||
clear(app.nav.regCache)
|
clear(app.nav.regCache)
|
||||||
app.ui.sxScreen.lastFile = ""
|
|
||||||
}
|
}
|
||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
case "scrolloff":
|
case "scrolloff":
|
||||||
@@ -430,6 +432,8 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
gOpts.truncatepct = n
|
gOpts.truncatepct = n
|
||||||
|
case "visualfmt":
|
||||||
|
gOpts.visualfmt = e.val
|
||||||
case "waitmsg":
|
case "waitmsg":
|
||||||
gOpts.waitmsg = e.val
|
gOpts.waitmsg = e.val
|
||||||
default:
|
default:
|
||||||
@@ -500,9 +504,9 @@ func (e *setLocalExpr) eval(app *app, args []string) {
|
|||||||
toks := strings.Split(e.val, ":")
|
toks := strings.Split(e.val, ":")
|
||||||
for _, s := range toks {
|
for _, s := range toks {
|
||||||
switch s {
|
switch s {
|
||||||
case "size", "time", "atime", "ctime", "perm", "user", "group":
|
case "size", "time", "atime", "ctime", "perm", "user", "group", "custom":
|
||||||
default:
|
default:
|
||||||
app.ui.echoerr("info: should consist of 'size', 'time', 'atime', 'ctime', 'perm', 'user' or 'group' separated with colon")
|
app.ui.echoerr("info: should consist of 'size', 'time', 'atime', 'ctime', 'perm', 'user', 'group' or 'custom' separated with colon")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,9 +545,29 @@ func (e *setLocalExpr) eval(app *app, args []string) {
|
|||||||
|
|
||||||
func (e *mapExpr) eval(app *app, args []string) {
|
func (e *mapExpr) eval(app *app, args []string) {
|
||||||
if e.expr == nil {
|
if e.expr == nil {
|
||||||
delete(gOpts.keys, e.keys)
|
delete(gOpts.nkeys, e.keys)
|
||||||
|
delete(gOpts.vkeys, e.keys)
|
||||||
} else {
|
} else {
|
||||||
gOpts.keys[e.keys] = e.expr
|
gOpts.nkeys[e.keys] = e.expr
|
||||||
|
gOpts.vkeys[e.keys] = e.expr
|
||||||
|
}
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *nmapExpr) eval(app *app, args []string) {
|
||||||
|
if e.expr == nil {
|
||||||
|
delete(gOpts.nkeys, e.keys)
|
||||||
|
} else {
|
||||||
|
gOpts.nkeys[e.keys] = e.expr
|
||||||
|
}
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *vmapExpr) eval(app *app, args []string) {
|
||||||
|
if e.expr == nil {
|
||||||
|
delete(gOpts.vkeys, e.keys)
|
||||||
|
} else {
|
||||||
|
gOpts.vkeys[e.keys] = e.expr
|
||||||
}
|
}
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
@@ -591,6 +615,17 @@ func onChdir(app *app) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func onLoad(app *app, files []string) {
|
||||||
|
// prevent infinite loops
|
||||||
|
if !gOpts.dircache {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd, ok := gOpts.cmds["on-load"]; ok {
|
||||||
|
cmd.eval(app, files)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func onFocusGained(app *app) {
|
func onFocusGained(app *app) {
|
||||||
if cmd, ok := gOpts.cmds["on-focus-gained"]; ok {
|
if cmd, ok := gOpts.cmds["on-focus-gained"]; ok {
|
||||||
cmd.eval(app, nil)
|
cmd.eval(app, nil)
|
||||||
@@ -790,6 +825,16 @@ func normal(app *app) {
|
|||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
|
|
||||||
|
// ensure the mode indicator in `statfmt` is updated properly
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
func visual(app *app) {
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
dir.visualAnchor = dir.ind
|
||||||
|
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
func insert(app *app, arg string) {
|
func insert(app *app, arg string) {
|
||||||
@@ -1285,11 +1330,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.nav.invert()
|
app.nav.invert()
|
||||||
case "invert-below":
|
|
||||||
if !app.nav.init {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
app.nav.invertBelow()
|
|
||||||
case "unselect":
|
case "unselect":
|
||||||
app.nav.unselect()
|
app.nav.unselect()
|
||||||
case "calcdirsize":
|
case "calcdirsize":
|
||||||
@@ -1306,8 +1346,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
case "clearmaps":
|
case "clearmaps":
|
||||||
// leave `:` and cmaps bound so the user can still exit using `:quit`
|
// leave `:` and cmaps bound so the user can still exit using `:quit`
|
||||||
clear(gOpts.keys)
|
clear(gOpts.nkeys)
|
||||||
gOpts.keys[":"] = &callExpr{"read", nil, 1}
|
clear(gOpts.vkeys)
|
||||||
|
gOpts.nkeys[":"] = &callExpr{"read", nil, 1}
|
||||||
|
gOpts.vkeys[":"] = &callExpr{"read", nil, 1}
|
||||||
case "copy":
|
case "copy":
|
||||||
if !app.nav.init {
|
if !app.nav.init {
|
||||||
return
|
return
|
||||||
@@ -1433,7 +1475,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
if gOpts.sixel {
|
if gOpts.sixel {
|
||||||
clear(app.nav.regCache)
|
clear(app.nav.regCache)
|
||||||
app.ui.sxScreen.lastFile = ""
|
app.ui.sxScreen.forceClear = true
|
||||||
}
|
}
|
||||||
for _, dir := range app.nav.dirs {
|
for _, dir := range app.nav.dirs {
|
||||||
dir.boundPos(app.nav.height)
|
dir.boundPos(app.nav.height)
|
||||||
@@ -2007,7 +2049,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
|
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
|
||||||
}
|
}
|
||||||
case "cmd-history-next":
|
case "cmd-history-next":
|
||||||
if app.ui.cmdPrefix == "" || app.ui.cmdPrefix == ">" {
|
if !slices.Contains([]string{":", "$", "!", "%", "&"}, app.ui.cmdPrefix) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if app.cmdHistoryInd > 0 {
|
if app.cmdHistoryInd > 0 {
|
||||||
@@ -2025,7 +2067,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.cmdPrefix = cmd.prefix
|
app.ui.cmdPrefix = cmd.prefix
|
||||||
app.ui.cmdAccLeft = []rune(cmd.value)
|
app.ui.cmdAccLeft = []rune(cmd.value)
|
||||||
case "cmd-history-prev":
|
case "cmd-history-prev":
|
||||||
if app.ui.cmdPrefix == ">" {
|
if !slices.Contains([]string{":", "$", "!", "%", "&", ""}, app.ui.cmdPrefix) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if app.cmdHistoryInd == len(app.cmdHistory) {
|
if app.cmdHistoryInd == len(app.cmdHistory) {
|
||||||
@@ -2179,7 +2221,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
ind := locs[len(locs)-1][3]
|
ind := locs[len(locs)-1][3]
|
||||||
app.ui.cmdYankBuf = []rune(string(app.ui.cmdAccLeft)[ind:])
|
app.ui.cmdYankBuf = []rune(string(app.ui.cmdAccLeft)[ind:])
|
||||||
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:ind]
|
app.ui.cmdAccLeft = []rune(string(app.ui.cmdAccLeft)[:ind])
|
||||||
update(app)
|
update(app)
|
||||||
case "cmd-uppercase-word":
|
case "cmd-uppercase-word":
|
||||||
if len(app.ui.cmdAccRight) == 0 {
|
if len(app.ui.cmdAccRight) == 0 {
|
||||||
@@ -2237,6 +2279,102 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
[]rune(string(app.ui.cmdAccLeft)[end2:]),
|
[]rune(string(app.ui.cmdAccLeft)[end2:]),
|
||||||
)
|
)
|
||||||
update(app)
|
update(app)
|
||||||
|
case "addcustominfo":
|
||||||
|
var k, v string
|
||||||
|
switch len(e.args) {
|
||||||
|
case 1:
|
||||||
|
k, v = e.args[0], ""
|
||||||
|
case 2:
|
||||||
|
k, v = e.args[0], e.args[1]
|
||||||
|
default:
|
||||||
|
app.ui.echoerr("addcustominfo: requires either 1 or 2 arguments")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
path, err := filepath.Abs(replaceTilde(k))
|
||||||
|
if err != nil {
|
||||||
|
app.ui.echoerrf("addcustominfo: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dir := filepath.Dir(path)
|
||||||
|
d, ok := app.nav.dirCache[dir]
|
||||||
|
if !ok {
|
||||||
|
app.ui.echoerrf("addcustominfo: dir not loaded: %s", dir)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var f *file
|
||||||
|
for _, file := range d.allFiles {
|
||||||
|
if file.path == path {
|
||||||
|
f = file
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if f == nil {
|
||||||
|
app.ui.echoerrf("addcustominfo: file not found: %s", path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(strings.Trim(v, " ")) == 0 {
|
||||||
|
v = ""
|
||||||
|
}
|
||||||
|
if f.customInfo != v {
|
||||||
|
f.customInfo = v
|
||||||
|
// only sort when order changes
|
||||||
|
if getSortBy(dir) == customSort {
|
||||||
|
d.sort()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "visual":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
visual(app)
|
||||||
|
case "visual-accept":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
for _, path := range dir.visualSelections() {
|
||||||
|
if _, ok := app.nav.selections[path]; !ok {
|
||||||
|
app.nav.selections[path] = app.nav.selectionInd
|
||||||
|
app.nav.selectionInd++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// resetting visual mode here instead of inside `normal()`
|
||||||
|
// allows us to use visual mode inside search, find etc.
|
||||||
|
dir.visualAnchor = -1
|
||||||
|
normal(app)
|
||||||
|
case "visual-unselect":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
for _, path := range dir.visualSelections() {
|
||||||
|
delete(app.nav.selections, path)
|
||||||
|
}
|
||||||
|
if len(app.nav.selections) == 0 {
|
||||||
|
app.nav.selectionInd = 0
|
||||||
|
}
|
||||||
|
dir.visualAnchor = -1
|
||||||
|
normal(app)
|
||||||
|
case "visual-discard":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
dir.visualAnchor = -1
|
||||||
|
normal(app)
|
||||||
|
case "visual-change":
|
||||||
|
if !app.nav.isVisualMode() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
beg := max(dir.ind-dir.pos, 0)
|
||||||
|
dir.ind, dir.visualAnchor = dir.visualAnchor, dir.ind
|
||||||
|
dir.pos = dir.ind - beg
|
||||||
|
dir.boundPos(app.nav.height)
|
||||||
default:
|
default:
|
||||||
cmd, ok := gOpts.cmds[e.name]
|
cmd, ok := gOpts.cmds[e.name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -294,6 +294,18 @@ var gEvalTests = []struct {
|
|||||||
[]expr{&mapExpr{"gh", &listExpr{[]expr{&callExpr{"cd", []string{"~"}, 1}}, 1}}},
|
[]expr{&mapExpr{"gh", &listExpr{[]expr{&callExpr{"cd", []string{"~"}, 1}}, 1}}},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"nmap <space> :toggle; down",
|
||||||
|
[]string{"nmap", "<space>", ":", "toggle", ";", "down", "\n", "\n"},
|
||||||
|
[]expr{&nmapExpr{"<space>", &listExpr{[]expr{&callExpr{"toggle", nil, 1}, &callExpr{"down", nil, 1}}, 1}}},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"vmap <esc> visual-accept",
|
||||||
|
[]string{"vmap", "<esc>", "visual-accept", "\n"},
|
||||||
|
[]expr{&vmapExpr{"<esc>", &callExpr{"visual-accept", nil, 1}}},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"cmap <c-g> cmd-escape",
|
"cmap <c-g> cmd-escape",
|
||||||
[]string{"cmap", "<c-g>", "cmd-escape", "\n"},
|
[]string{"cmap", "<c-g>", "cmd-escape", "\n"},
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
[ -z $version ] && version=$(git describe --tags)
|
[ -z $version ] && version=$(git describe --tags)
|
||||||
[ -z $date ] && date=$(date +%F)
|
[ -z $date ] && date=$(date +%F)
|
||||||
|
|
||||||
PANDOC_IMAGE=pandoc/minimal:2.11
|
PANDOC_IMAGE=pandoc/minimal:3.7
|
||||||
|
|
||||||
docker run --rm -v "$PWD:/data" --user "$(id -u):$(id -g)" $PANDOC_IMAGE \
|
docker run --rm -v "$PWD:/data" --user "$(id -u):$(id -g)" $PANDOC_IMAGE \
|
||||||
--standalone \
|
--standalone \
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ require (
|
|||||||
github.com/fsnotify/fsnotify v1.9.0
|
github.com/fsnotify/fsnotify v1.9.0
|
||||||
github.com/gdamore/tcell/v2 v2.8.1
|
github.com/gdamore/tcell/v2 v2.8.1
|
||||||
github.com/mattn/go-runewidth v0.0.16
|
github.com/mattn/go-runewidth v0.0.16
|
||||||
golang.org/x/sys v0.32.0
|
golang.org/x/sys v0.33.0
|
||||||
golang.org/x/term v0.31.0
|
golang.org/x/term v0.32.0
|
||||||
golang.org/x/text v0.24.0
|
golang.org/x/text v0.26.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||||
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
@@ -66,8 +66,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
|||||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||||
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||||
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
|
golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
|
||||||
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
|
golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
@@ -77,8 +77,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
|||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
|
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||||
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
|
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
|||||||
@@ -87,13 +87,6 @@ func exportEnvVars() {
|
|||||||
level++
|
level++
|
||||||
|
|
||||||
os.Setenv("LF_LEVEL", strconv.Itoa(level))
|
os.Setenv("LF_LEVEL", strconv.Itoa(level))
|
||||||
|
|
||||||
lfPath, err := os.Executable()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("getting path to lf binary: %s", err)
|
|
||||||
lfPath = "lf"
|
|
||||||
}
|
|
||||||
os.Setenv("lf", quoteString(lfPath))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// used by exportOpts below
|
// used by exportOpts below
|
||||||
@@ -133,7 +126,7 @@ func getOptsMap() map[string]string {
|
|||||||
name := "lf_" + t.Field(i).Name
|
name := "lf_" + t.Field(i).Name
|
||||||
|
|
||||||
// Skip maps
|
// Skip maps
|
||||||
if name == "lf_keys" || name == "lf_cmdkeys" || name == "lf_cmds" {
|
if name == "lf_nkeys" || name == "lf_vkeys" || name == "lf_cmdkeys" || name == "lf_cmds" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +143,15 @@ func getOptsMap() map[string]string {
|
|||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func exportLfPath() {
|
||||||
|
lfPath, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("getting path to lf binary: %s", err)
|
||||||
|
lfPath = "lf"
|
||||||
|
}
|
||||||
|
os.Setenv("lf", quoteString(lfPath))
|
||||||
|
}
|
||||||
|
|
||||||
func exportOpts() {
|
func exportOpts() {
|
||||||
for key, value := range getOptsMap() {
|
for key, value := range getOptsMap() {
|
||||||
os.Setenv(key, value)
|
os.Setenv(key, value)
|
||||||
@@ -296,6 +298,14 @@ func main() {
|
|||||||
gSocketProt = gDefaultSocketProt
|
gSocketProt = gDefaultSocketProt
|
||||||
gSocketPath = gDefaultSocketPath
|
gSocketPath = gDefaultSocketPath
|
||||||
|
|
||||||
|
if gLogPath != "" {
|
||||||
|
path, err := filepath.Abs(gLogPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("getting log path: %s", err)
|
||||||
|
}
|
||||||
|
gLogPath = path
|
||||||
|
}
|
||||||
|
|
||||||
if *cpuprofile != "" {
|
if *cpuprofile != "" {
|
||||||
f, err := os.Create(*cpuprofile)
|
f, err := os.Create(*cpuprofile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -317,14 +327,6 @@ func main() {
|
|||||||
log.Fatalf("remote command: %s", err)
|
log.Fatalf("remote command: %s", err)
|
||||||
}
|
}
|
||||||
case *serverMode:
|
case *serverMode:
|
||||||
if gLogPath != "" && !filepath.IsAbs(gLogPath) {
|
|
||||||
wd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("getting current directory: %s", err)
|
|
||||||
} else {
|
|
||||||
gLogPath = filepath.Join(wd, gLogPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os.Chdir(gUser.HomeDir)
|
os.Chdir(gUser.HomeDir)
|
||||||
serve()
|
serve()
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/Xuanwo/go-locale"
|
"github.com/Xuanwo/go-locale"
|
||||||
"github.com/mattn/go-runewidth"
|
"github.com/mattn/go-runewidth"
|
||||||
@@ -31,6 +32,14 @@ func replaceTilde(s string) string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func evalSymlinks(path string) string {
|
||||||
|
if target, err := filepath.EvalSymlinks(path); err == nil {
|
||||||
|
return target
|
||||||
|
}
|
||||||
|
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
func runeSliceWidth(rs []rune) int {
|
func runeSliceWidth(rs []rune) int {
|
||||||
w := 0
|
w := 0
|
||||||
for _, r := range rs {
|
for _, r := range rs {
|
||||||
@@ -326,7 +335,8 @@ func getFileExtension(file fs.FileInfo) string {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
|
reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
|
||||||
reRulerSub = regexp.MustCompile(`%[apmcsfithd]|%\{[^}]+\}`)
|
reRulerSub = regexp.MustCompile(`%[apmcsvfithPd]|%\{[^}]+\}`)
|
||||||
|
reSixelSize = regexp.MustCompile(`"1;1;(\d+);(\d+)`)
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -369,6 +379,50 @@ func makeCollator(localeStr string, opts ...collate.Option) (*collate.Collator,
|
|||||||
return collate.New(localeTag, opts...), nil
|
return collate.New(localeTag, opts...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function deletes entries from a map if the key is either the given path
|
||||||
|
// or a subpath of it.
|
||||||
|
// This is useful for clearing cached data when a directory is moved or deleted.
|
||||||
|
func deletePathRecursive[T any](m map[string]T, path string) {
|
||||||
|
delete(m, path)
|
||||||
|
prefix := path + string(filepath.Separator)
|
||||||
|
for k := range m {
|
||||||
|
if strings.HasPrefix(k, prefix) {
|
||||||
|
delete(m, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function is used to remove style-related ANSI escape sequences from
|
||||||
|
// a given string.
|
||||||
|
//
|
||||||
|
// *Note*: this function is based entirely on `printLength()` and strips only
|
||||||
|
// style-related escape sequences and the `erase in line` sequence. Other codes
|
||||||
|
// (e.g., cursor moves), as well as broken escape sequences, aren't removed.
|
||||||
|
// This prevents mismatches between the two functions and avoids misalignment
|
||||||
|
// when rendering the UI.
|
||||||
|
func stripAnsi(s string) string {
|
||||||
|
var b strings.Builder
|
||||||
|
slen := len(s)
|
||||||
|
for i := 0; i < slen; i++ {
|
||||||
|
r, w := utf8.DecodeRuneInString(s[i:])
|
||||||
|
|
||||||
|
if r == gEscapeCode && i+1 < slen && s[i+1] == '[' {
|
||||||
|
j := strings.IndexAny(s[i:min(slen, i+64)], "mK")
|
||||||
|
if j == -1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
i += j
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
i += w - 1
|
||||||
|
b.WriteRune(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.String()
|
||||||
|
}
|
||||||
|
|
||||||
// We don't need no generic code
|
// We don't need no generic code
|
||||||
// We don't need no type control
|
// We don't need no type control
|
||||||
// No dark templates in compiler
|
// No dark templates in compiler
|
||||||
|
|||||||
@@ -386,3 +386,35 @@ func TestLocaleNaturalLess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStripAnsi(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
s string
|
||||||
|
exp string
|
||||||
|
}{
|
||||||
|
{"", ""}, // empty
|
||||||
|
{"foo bar", "foo bar"}, // plain text
|
||||||
|
{"\033[31mRed\033[0m", "Red"}, // octal syntax
|
||||||
|
{"\x1b[31mRed\x1b[0m", "Red"}, // hexadecimal syntax
|
||||||
|
{"foo\x1b[31mRed", "fooRed"}, // no reset parameter
|
||||||
|
{
|
||||||
|
"foo\x1b[1;31;102mBoldRedGreen\x1b[0mbar",
|
||||||
|
"fooBoldRedGreenbar",
|
||||||
|
}, // multiple attributes
|
||||||
|
{
|
||||||
|
"misc.go:func \x1b[01;31m\x1b[KstripAnsi\x1b[m\x1b[K(s string) string {",
|
||||||
|
"misc.go:func stripAnsi(s string) string {",
|
||||||
|
}, // `grep` output containing `erase in line` sequence
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
if got := stripAnsi(test.s); got != test.exp {
|
||||||
|
t.Errorf("at input %q expected %q but got %q", test.s, test.exp, got)
|
||||||
|
}
|
||||||
|
// we rely on both functions extracting the same runes
|
||||||
|
// to avoid misalignment
|
||||||
|
if printLength(test.s) != len(stripAnsi(test.s)) {
|
||||||
|
t.Errorf("at input %q expected '%d' but got '%d'", test.s, printLength(test.s), len(stripAnsi(test.s)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,13 +37,13 @@ type file struct {
|
|||||||
dirSize int64
|
dirSize int64
|
||||||
accessTime time.Time
|
accessTime time.Time
|
||||||
changeTime time.Time
|
changeTime time.Time
|
||||||
|
customInfo string
|
||||||
ext string
|
ext string
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFile(path string) *file {
|
func newFile(path string) *file {
|
||||||
lstat, err := os.Lstat(path)
|
lstat, err := os.Lstat(path)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("getting file information: %s", err)
|
log.Printf("getting file information: %s", err)
|
||||||
return &file{
|
return &file{
|
||||||
@@ -55,6 +55,7 @@ func newFile(path string) *file {
|
|||||||
dirSize: -1,
|
dirSize: -1,
|
||||||
accessTime: time.Unix(0, 0),
|
accessTime: time.Unix(0, 0),
|
||||||
changeTime: time.Unix(0, 0),
|
changeTime: time.Unix(0, 0),
|
||||||
|
customInfo: "",
|
||||||
ext: "",
|
ext: "",
|
||||||
err: err,
|
err: err,
|
||||||
}
|
}
|
||||||
@@ -114,6 +115,7 @@ func newFile(path string) *file {
|
|||||||
dirSize: -1,
|
dirSize: -1,
|
||||||
accessTime: at,
|
accessTime: at,
|
||||||
changeTime: ct,
|
changeTime: ct,
|
||||||
|
customInfo: "",
|
||||||
ext: getFileExtension(lstat),
|
ext: getFileExtension(lstat),
|
||||||
err: nil,
|
err: nil,
|
||||||
}
|
}
|
||||||
@@ -169,6 +171,7 @@ type dir struct {
|
|||||||
dironly bool // dironly value from last sort
|
dironly bool // dironly value from last sort
|
||||||
hidden bool // hidden value from last sort
|
hidden bool // hidden value from last sort
|
||||||
reverse bool // reverse value from last sort
|
reverse bool // reverse value from last sort
|
||||||
|
visualAnchor int // index where visual mode was initiated
|
||||||
hiddenfiles []string // hiddenfiles value from last sort
|
hiddenfiles []string // hiddenfiles value from last sort
|
||||||
filter []string // last filter for this directory
|
filter []string // last filter for this directory
|
||||||
ignorecase bool // ignorecase value from last sort
|
ignorecase bool // ignorecase value from last sort
|
||||||
@@ -190,6 +193,7 @@ func newDir(path string) *dir {
|
|||||||
path: path,
|
path: path,
|
||||||
files: files,
|
files: files,
|
||||||
allFiles: files,
|
allFiles: files,
|
||||||
|
visualAnchor: -1,
|
||||||
noPerm: os.IsPermission(err),
|
noPerm: os.IsPermission(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,6 +247,27 @@ func (dir *dir) sort() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
case customSort:
|
||||||
|
if collator, err := makeCollator(dir.locale, collate.Numeric); err == nil {
|
||||||
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
|
s1, s2 := normalize(stripAnsi(dir.files[i].customInfo), stripAnsi(dir.files[j].customInfo), dir.ignorecase, dir.ignoredia)
|
||||||
|
result := collator.CompareString(s1, s2)
|
||||||
|
if !dir.reverse {
|
||||||
|
return result < 0
|
||||||
|
} else {
|
||||||
|
return result > 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
|
s1, s2 := normalize(stripAnsi(dir.files[i].customInfo), stripAnsi(dir.files[j].customInfo), dir.ignorecase, dir.ignoredia)
|
||||||
|
if !dir.reverse {
|
||||||
|
return naturalLess(s1, s2)
|
||||||
|
} else {
|
||||||
|
return naturalLess(s2, s1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
case nameSort:
|
case nameSort:
|
||||||
if collator, err := makeCollator(dir.locale); err == nil {
|
if collator, err := makeCollator(dir.locale); err == nil {
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
@@ -388,6 +413,37 @@ func (dir *dir) name() string {
|
|||||||
return dir.files[dir.ind].Name()
|
return dir.files[dir.ind].Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *dir) fileNames() []string {
|
||||||
|
names := []string{}
|
||||||
|
for _, file := range d.files {
|
||||||
|
names = append(names, file.path)
|
||||||
|
}
|
||||||
|
|
||||||
|
return names
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nav *nav) isVisualMode() bool {
|
||||||
|
return nav.init && nav.currDir().visualAnchor != -1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dir *dir) visualSelections() []string {
|
||||||
|
paths := []string{}
|
||||||
|
if dir.visualAnchor == -1 || len(dir.files) == 0 {
|
||||||
|
return paths
|
||||||
|
}
|
||||||
|
|
||||||
|
beg, end := dir.ind, dir.visualAnchor
|
||||||
|
if beg > end {
|
||||||
|
beg, end = end, beg
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, f := range dir.files[beg : end+1] {
|
||||||
|
paths = append(paths, f.path)
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths
|
||||||
|
}
|
||||||
|
|
||||||
func (dir *dir) sel(name string, height int) {
|
func (dir *dir) sel(name string, height int) {
|
||||||
if len(dir.files) == 0 {
|
if len(dir.files) == 0 {
|
||||||
dir.ind, dir.pos = 0, 0
|
dir.ind, dir.pos = 0, 0
|
||||||
@@ -487,6 +543,7 @@ func (nav *nav) loadDirInternal(path string) *dir {
|
|||||||
hidden: getHidden(path),
|
hidden: getHidden(path),
|
||||||
reverse: getReverse(path),
|
reverse: getReverse(path),
|
||||||
locale: getLocale(path),
|
locale: getLocale(path),
|
||||||
|
visualAnchor: -1,
|
||||||
hiddenfiles: gOpts.hiddenfiles,
|
hiddenfiles: gOpts.hiddenfiles,
|
||||||
ignorecase: gOpts.ignorecase,
|
ignorecase: gOpts.ignorecase,
|
||||||
ignoredia: gOpts.ignoredia,
|
ignoredia: gOpts.ignoredia,
|
||||||
@@ -694,8 +751,15 @@ func (nav *nav) exportFiles() {
|
|||||||
}
|
}
|
||||||
currSelections := strings.Join(selections, gOpts.filesep)
|
currSelections := strings.Join(selections, gOpts.filesep)
|
||||||
|
|
||||||
|
var vSelections []string
|
||||||
|
for _, selection := range nav.currDir().visualSelections() {
|
||||||
|
vSelections = append(vSelections, quoteString(selection))
|
||||||
|
}
|
||||||
|
currVSelections := strings.Join(vSelections, gOpts.filesep)
|
||||||
|
|
||||||
os.Setenv("f", currFile)
|
os.Setenv("f", currFile)
|
||||||
os.Setenv("fs", currSelections)
|
os.Setenv("fs", currSelections)
|
||||||
|
os.Setenv("fv", currVSelections)
|
||||||
os.Setenv("PWD", quoteString(nav.currDir().path))
|
os.Setenv("PWD", quoteString(nav.currDir().path))
|
||||||
|
|
||||||
if len(selections) == 0 {
|
if len(selections) == 0 {
|
||||||
@@ -1066,7 +1130,7 @@ func (nav *nav) bottom() bool {
|
|||||||
|
|
||||||
old := dir.ind
|
old := dir.ind
|
||||||
|
|
||||||
dir.ind = len(dir.files) - 1
|
dir.ind = max(len(dir.files)-1, 0)
|
||||||
dir.pos = min(dir.ind, nav.height-1)
|
dir.pos = min(dir.ind, nav.height-1)
|
||||||
|
|
||||||
return old != dir.ind
|
return old != dir.ind
|
||||||
@@ -1161,6 +1225,8 @@ func (nav *nav) toggle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) tagToggleSelection(path string, tag string) {
|
func (nav *nav) tagToggleSelection(path string, tag string) {
|
||||||
|
path = evalSymlinks(path)
|
||||||
|
|
||||||
if _, ok := nav.tags[path]; ok {
|
if _, ok := nav.tags[path]; ok {
|
||||||
delete(nav.tags, path)
|
delete(nav.tags, path)
|
||||||
} else {
|
} else {
|
||||||
@@ -1196,28 +1262,20 @@ func (nav *nav) tag(tag string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range list {
|
for _, path := range list {
|
||||||
nav.tags[path] = tag
|
nav.tags[evalSymlinks(path)] = tag
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) invertAfter(ix int) {
|
func (nav *nav) invert() {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
for _, f := range dir.files[ix:] {
|
for _, f := range dir.files {
|
||||||
path := filepath.Join(dir.path, f.Name())
|
path := filepath.Join(dir.path, f.Name())
|
||||||
nav.toggleSelection(path)
|
nav.toggleSelection(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) invert() {
|
|
||||||
nav.invertAfter(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (nav *nav) invertBelow() {
|
|
||||||
nav.invertAfter(nav.currDir().ind)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (nav *nav) unselect() {
|
func (nav *nav) unselect() {
|
||||||
clear(nav.selections)
|
clear(nav.selections)
|
||||||
nav.selectionInd = 0
|
nav.selectionInd = 0
|
||||||
@@ -1323,13 +1381,13 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {
|
|||||||
file := filepath.Base(src)
|
file := filepath.Base(src)
|
||||||
dst := filepath.Join(dstDir, file)
|
dst := filepath.Join(dstDir, file)
|
||||||
|
|
||||||
dstStat, err := os.Stat(dst)
|
if dstStat, err := os.Stat(dst); err == nil {
|
||||||
if os.SameFile(srcStat, dstStat) {
|
if os.SameFile(srcStat, dstStat) {
|
||||||
errCount++
|
errCount++
|
||||||
echo.args[0] = fmt.Sprintf("[%d] rename %s %s: source and destination are the same file", errCount, src, dst)
|
echo.args[0] = fmt.Sprintf("[%d] rename %s %s: source and destination are the same file", errCount, src, dst)
|
||||||
app.ui.exprChan <- echo
|
app.ui.exprChan <- echo
|
||||||
continue
|
continue
|
||||||
} else if !os.IsNotExist(err) {
|
}
|
||||||
ext := getFileExtension(dstStat)
|
ext := getFileExtension(dstStat)
|
||||||
basename := file[:len(file)-len(ext)]
|
basename := file[:len(file)-len(ext)]
|
||||||
var newPath string
|
var newPath string
|
||||||
@@ -1486,8 +1544,8 @@ func (nav *nav) rename() error {
|
|||||||
// existed and was deleted. In this case the cache entries should be deleted
|
// existed and was deleted. In this case the cache entries should be deleted
|
||||||
// before loading newPath to prevent displaying a stale preview. However,
|
// before loading newPath to prevent displaying a stale preview. However,
|
||||||
// this clears only the current instance of lf, and not any other instances.
|
// this clears only the current instance of lf, and not any other instances.
|
||||||
delete(nav.regCache, newPath)
|
deletePathRecursive(nav.regCache, newPath)
|
||||||
delete(nav.dirCache, newPath)
|
deletePathRecursive(nav.dirCache, newPath)
|
||||||
dir := nav.loadDir(filepath.Dir(newPath))
|
dir := nav.loadDir(filepath.Dir(newPath))
|
||||||
|
|
||||||
if dir.loading {
|
if dir.loading {
|
||||||
@@ -1516,15 +1574,20 @@ func (nav *nav) sync() error {
|
|||||||
nav.saves[f] = cp
|
nav.saves[f] = cp
|
||||||
}
|
}
|
||||||
|
|
||||||
oldmarks := nav.marks
|
tempmarks := make(map[string]string)
|
||||||
errMarks := nav.readMarks()
|
|
||||||
for _, ch := range gOpts.tempmarks {
|
for _, ch := range gOpts.tempmarks {
|
||||||
tmp := string(ch)
|
k := string(ch)
|
||||||
if v, e := oldmarks[tmp]; e {
|
if v, ok := nav.marks[k]; ok {
|
||||||
nav.marks[tmp] = v
|
tempmarks[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
errMarks := nav.readMarks()
|
||||||
|
for k, v := range tempmarks {
|
||||||
|
nav.marks[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
err = nav.readTags()
|
err = nav.readTags()
|
||||||
|
|
||||||
if errMarks != nil {
|
if errMarks != nil {
|
||||||
return errMarks
|
return errMarks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"maps"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -16,6 +17,7 @@ const (
|
|||||||
atimeSort sortMethod = "atime"
|
atimeSort sortMethod = "atime"
|
||||||
ctimeSort sortMethod = "ctime"
|
ctimeSort sortMethod = "ctime"
|
||||||
extSort sortMethod = "ext"
|
extSort sortMethod = "ext"
|
||||||
|
customSort sortMethod = "custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
func isValidSortMethod(method sortMethod) bool {
|
func isValidSortMethod(method sortMethod) bool {
|
||||||
@@ -25,10 +27,11 @@ func isValidSortMethod(method sortMethod) bool {
|
|||||||
method == timeSort ||
|
method == timeSort ||
|
||||||
method == atimeSort ||
|
method == atimeSort ||
|
||||||
method == ctimeSort ||
|
method == ctimeSort ||
|
||||||
method == extSort
|
method == extSort ||
|
||||||
|
method == customSort
|
||||||
}
|
}
|
||||||
|
|
||||||
const invalidSortErrorMessage = `sortby: value should either be 'natural', 'name', 'size', 'time', 'atime', 'ctime' or 'ext'`
|
const invalidSortErrorMessage = `sortby: value should either be 'natural', 'name', 'size', 'time', 'atime', 'ctime', 'ext' or 'custom'`
|
||||||
|
|
||||||
var gOpts struct {
|
var gOpts struct {
|
||||||
anchorfind bool
|
anchorfind bool
|
||||||
@@ -62,6 +65,7 @@ var gOpts struct {
|
|||||||
reverse bool
|
reverse bool
|
||||||
roundbox bool
|
roundbox bool
|
||||||
selectfmt string
|
selectfmt string
|
||||||
|
visualfmt string
|
||||||
showbinds bool
|
showbinds bool
|
||||||
sixel bool
|
sixel bool
|
||||||
sortby sortMethod
|
sortby sortMethod
|
||||||
@@ -97,7 +101,8 @@ var gOpts struct {
|
|||||||
rulerfmt string
|
rulerfmt string
|
||||||
preserve []string
|
preserve []string
|
||||||
shellopts []string
|
shellopts []string
|
||||||
keys map[string]expr
|
nkeys map[string]expr
|
||||||
|
vkeys map[string]expr
|
||||||
cmdkeys map[string]expr
|
cmdkeys map[string]expr
|
||||||
cmds map[string]expr
|
cmds map[string]expr
|
||||||
user map[string]string
|
user map[string]string
|
||||||
@@ -229,6 +234,7 @@ func init() {
|
|||||||
gOpts.reverse = false
|
gOpts.reverse = false
|
||||||
gOpts.roundbox = false
|
gOpts.roundbox = false
|
||||||
gOpts.selectfmt = "\033[7;35m"
|
gOpts.selectfmt = "\033[7;35m"
|
||||||
|
gOpts.visualfmt = "\033[7;36m"
|
||||||
gOpts.showbinds = true
|
gOpts.showbinds = true
|
||||||
gOpts.sixel = false
|
gOpts.sixel = false
|
||||||
gOpts.sortby = naturalSort
|
gOpts.sortby = naturalSort
|
||||||
@@ -261,14 +267,15 @@ func init() {
|
|||||||
gOpts.hiddenfiles = gDefaultHiddenFiles
|
gOpts.hiddenfiles = gDefaultHiddenFiles
|
||||||
gOpts.history = true
|
gOpts.history = true
|
||||||
gOpts.info = nil
|
gOpts.info = nil
|
||||||
gOpts.rulerfmt = " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t"
|
gOpts.rulerfmt = " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t"
|
||||||
gOpts.preserve = []string{"mode"}
|
gOpts.preserve = []string{"mode"}
|
||||||
gOpts.shellopts = nil
|
gOpts.shellopts = nil
|
||||||
gOpts.tempmarks = "'"
|
gOpts.tempmarks = "'"
|
||||||
gOpts.numberfmt = "\033[33m"
|
gOpts.numberfmt = "\033[33m"
|
||||||
gOpts.tagfmt = "\033[31m"
|
gOpts.tagfmt = "\033[31m"
|
||||||
|
|
||||||
gOpts.keys = map[string]expr{
|
// normal and visual mode
|
||||||
|
keys := map[string]expr{
|
||||||
"k": &callExpr{"up", nil, 1},
|
"k": &callExpr{"up", nil, 1},
|
||||||
"<up>": &callExpr{"up", nil, 1},
|
"<up>": &callExpr{"up", nil, 1},
|
||||||
"<m-up>": &callExpr{"up", nil, 1},
|
"<m-up>": &callExpr{"up", nil, 1},
|
||||||
@@ -299,9 +306,7 @@ func init() {
|
|||||||
"L": &callExpr{"low", nil, 1},
|
"L": &callExpr{"low", nil, 1},
|
||||||
"[": &callExpr{"jump-prev", nil, 1},
|
"[": &callExpr{"jump-prev", nil, 1},
|
||||||
"]": &callExpr{"jump-next", nil, 1},
|
"]": &callExpr{"jump-next", nil, 1},
|
||||||
"<space>": &listExpr{[]expr{&callExpr{"toggle", nil, 1}, &callExpr{"down", nil, 1}}, 1},
|
|
||||||
"t": &callExpr{"tag-toggle", nil, 1},
|
"t": &callExpr{"tag-toggle", nil, 1},
|
||||||
"v": &callExpr{"invert", nil, 1},
|
|
||||||
"u": &callExpr{"unselect", nil, 1},
|
"u": &callExpr{"unselect", nil, 1},
|
||||||
"y": &callExpr{"copy", nil, 1},
|
"y": &callExpr{"copy", nil, 1},
|
||||||
"d": &callExpr{"cut", nil, 1},
|
"d": &callExpr{"cut", nil, 1},
|
||||||
@@ -344,6 +349,20 @@ func init() {
|
|||||||
"gh": &callExpr{"cd", []string{"~"}, 1},
|
"gh": &callExpr{"cd", []string{"~"}, 1},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// insert bindings that apply to both normal & visual mode first
|
||||||
|
gOpts.nkeys = maps.Clone(keys)
|
||||||
|
// now add normal mode specific ones
|
||||||
|
gOpts.nkeys["<space>"] = &listExpr{[]expr{&callExpr{"toggle", nil, 1}, &callExpr{"down", nil, 1}}, 1}
|
||||||
|
gOpts.nkeys["V"] = &callExpr{"visual", nil, 1}
|
||||||
|
gOpts.nkeys["v"] = &callExpr{"invert", nil, 1}
|
||||||
|
|
||||||
|
// now do the same for visual mode
|
||||||
|
gOpts.vkeys = maps.Clone(keys)
|
||||||
|
gOpts.vkeys["<esc>"] = &callExpr{"visual-discard", nil, 1}
|
||||||
|
gOpts.vkeys["V"] = &callExpr{"visual-accept", nil, 1}
|
||||||
|
gOpts.vkeys["o"] = &callExpr{"visual-change", nil, 1}
|
||||||
|
|
||||||
|
// command line mode bindings can be assigned directly
|
||||||
gOpts.cmdkeys = map[string]expr{
|
gOpts.cmdkeys = map[string]expr{
|
||||||
"<space>": &callExpr{"cmd-insert", []string{" "}, 1},
|
"<space>": &callExpr{"cmd-insert", []string{" "}, 1},
|
||||||
"<esc>": &callExpr{"cmd-escape", nil, 1},
|
"<esc>": &callExpr{"cmd-escape", nil, 1},
|
||||||
|
|||||||
@@ -157,14 +157,20 @@ func shellKill(cmd *exec.Cmd) error {
|
|||||||
|
|
||||||
func setDefaults() {
|
func setDefaults() {
|
||||||
gOpts.cmds["open"] = &execExpr{"&", `$OPENER "$f"`}
|
gOpts.cmds["open"] = &execExpr{"&", `$OPENER "$f"`}
|
||||||
gOpts.keys["e"] = &execExpr{"$", `$EDITOR "$f"`}
|
gOpts.nkeys["e"] = &execExpr{"$", `$EDITOR "$f"`}
|
||||||
gOpts.keys["i"] = &execExpr{"$", `$PAGER "$f"`}
|
gOpts.vkeys["e"] = &execExpr{"$", `$EDITOR "$f"`}
|
||||||
gOpts.keys["w"] = &execExpr{"$", "$SHELL"}
|
gOpts.nkeys["i"] = &execExpr{"$", `$PAGER "$f"`}
|
||||||
|
gOpts.vkeys["i"] = &execExpr{"$", `$PAGER "$f"`}
|
||||||
|
gOpts.nkeys["w"] = &execExpr{"$", "$SHELL"}
|
||||||
|
gOpts.vkeys["w"] = &execExpr{"$", "$SHELL"}
|
||||||
|
|
||||||
gOpts.cmds["doc"] = &execExpr{"$", `"$lf" -doc | $PAGER`}
|
gOpts.cmds["doc"] = &execExpr{"$", `"$lf" -doc | $PAGER`}
|
||||||
gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1}
|
gOpts.nkeys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||||
|
gOpts.vkeys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||||
|
|
||||||
gOpts.cmds["maps"] = &execExpr{"$", `"$lf" -remote "query $id maps" | $PAGER`}
|
gOpts.cmds["maps"] = &execExpr{"$", `"$lf" -remote "query $id maps" | $PAGER`}
|
||||||
|
gOpts.cmds["nmaps"] = &execExpr{"$", `"$lf" -remote "query $id nmaps" | $PAGER`}
|
||||||
|
gOpts.cmds["vmaps"] = &execExpr{"$", `"$lf" -remote "query $id vmaps" | $PAGER`}
|
||||||
gOpts.cmds["cmaps"] = &execExpr{"$", `"$lf" -remote "query $id cmaps" | $PAGER`}
|
gOpts.cmds["cmaps"] = &execExpr{"$", `"$lf" -remote "query $id cmaps" | $PAGER`}
|
||||||
gOpts.cmds["cmds"] = &execExpr{"$", `"$lf" -remote "query $id cmds" | $PAGER`}
|
gOpts.cmds["cmds"] = &execExpr{"$", `"$lf" -remote "query $id cmds" | $PAGER`}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-4
@@ -143,14 +143,20 @@ func shellKill(cmd *exec.Cmd) error {
|
|||||||
|
|
||||||
func setDefaults() {
|
func setDefaults() {
|
||||||
gOpts.cmds["open"] = &execExpr{"&", "%OPENER% %f%"}
|
gOpts.cmds["open"] = &execExpr{"&", "%OPENER% %f%"}
|
||||||
gOpts.keys["e"] = &execExpr{"$", "%EDITOR% %f%"}
|
gOpts.nkeys["e"] = &execExpr{"$", "%EDITOR% %f%"}
|
||||||
gOpts.keys["i"] = &execExpr{"!", "%PAGER% %f%"}
|
gOpts.vkeys["e"] = &execExpr{"$", "%EDITOR% %f%"}
|
||||||
gOpts.keys["w"] = &execExpr{"$", "%SHELL%"}
|
gOpts.nkeys["i"] = &execExpr{"!", "%PAGER% %f%"}
|
||||||
|
gOpts.vkeys["i"] = &execExpr{"!", "%PAGER% %f%"}
|
||||||
|
gOpts.nkeys["w"] = &execExpr{"$", "%SHELL%"}
|
||||||
|
gOpts.vkeys["w"] = &execExpr{"$", "%SHELL%"}
|
||||||
|
|
||||||
gOpts.cmds["doc"] = &execExpr{"!", "%lf% -doc | %PAGER%"}
|
gOpts.cmds["doc"] = &execExpr{"!", "%lf% -doc | %PAGER%"}
|
||||||
gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1}
|
gOpts.nkeys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||||
|
gOpts.vkeys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||||
|
|
||||||
gOpts.cmds["maps"] = &execExpr{"!", `%lf% -remote "query %id% maps" | %PAGER%`}
|
gOpts.cmds["maps"] = &execExpr{"!", `%lf% -remote "query %id% maps" | %PAGER%`}
|
||||||
|
gOpts.cmds["nmaps"] = &execExpr{"!", `%lf% -remote "query %id% nmaps" | %PAGER%`}
|
||||||
|
gOpts.cmds["vmaps"] = &execExpr{"!", `%lf% -remote "query %id% vmaps" | %PAGER%`}
|
||||||
gOpts.cmds["cmaps"] = &execExpr{"!", `%lf% -remote "query %id% cmaps" | %PAGER%`}
|
gOpts.cmds["cmaps"] = &execExpr{"!", `%lf% -remote "query %id% cmaps" | %PAGER%`}
|
||||||
gOpts.cmds["cmds"] = &execExpr{"!", `%lf% -remote "query %id% cmds" | %PAGER%`}
|
gOpts.cmds["cmds"] = &execExpr{"!", `%lf% -remote "query %id% cmds" | %PAGER%`}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ package main
|
|||||||
// Expr = SetExpr
|
// Expr = SetExpr
|
||||||
// | SetLocalExpr
|
// | SetLocalExpr
|
||||||
// | MapExpr
|
// | MapExpr
|
||||||
|
// | NMapExpr
|
||||||
|
// | VMapExpr
|
||||||
// | CMapExpr
|
// | CMapExpr
|
||||||
// | CmdExpr
|
// | CmdExpr
|
||||||
// | CallExpr
|
// | CallExpr
|
||||||
@@ -17,6 +19,10 @@ package main
|
|||||||
//
|
//
|
||||||
// MapExpr = 'map' <keys> Expr
|
// MapExpr = 'map' <keys> Expr
|
||||||
//
|
//
|
||||||
|
// NMapExpr = 'nmap' <keys> Expr
|
||||||
|
//
|
||||||
|
// VMapExpr = 'vmap' <keys> Expr
|
||||||
|
//
|
||||||
// CMapExpr = 'cmap' <key> Expr
|
// CMapExpr = 'cmap' <key> Expr
|
||||||
//
|
//
|
||||||
// CmdExpr = 'cmd' <name> Expr
|
// CmdExpr = 'cmd' <name> Expr
|
||||||
@@ -68,6 +74,20 @@ type mapExpr struct {
|
|||||||
|
|
||||||
func (e *mapExpr) String() string { return fmt.Sprintf("map %s %s", e.keys, e.expr) }
|
func (e *mapExpr) String() string { return fmt.Sprintf("map %s %s", e.keys, e.expr) }
|
||||||
|
|
||||||
|
type nmapExpr struct {
|
||||||
|
keys string
|
||||||
|
expr expr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *nmapExpr) String() string { return fmt.Sprintf("nmap %s %s", e.keys, e.expr) }
|
||||||
|
|
||||||
|
type vmapExpr struct {
|
||||||
|
keys string
|
||||||
|
expr expr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *vmapExpr) String() string { return fmt.Sprintf("vmap %s %s", e.keys, e.expr) }
|
||||||
|
|
||||||
type cmapExpr struct {
|
type cmapExpr struct {
|
||||||
key string
|
key string
|
||||||
expr expr
|
expr expr
|
||||||
@@ -225,6 +245,34 @@ func (p *parser) parseExpr() expr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = &mapExpr{keys, expr}
|
result = &mapExpr{keys, expr}
|
||||||
|
case "nmap":
|
||||||
|
var expr expr
|
||||||
|
|
||||||
|
s.scan()
|
||||||
|
keys := s.tok
|
||||||
|
|
||||||
|
s.scan()
|
||||||
|
if s.typ != tokenSemicolon {
|
||||||
|
expr = p.parseExpr()
|
||||||
|
} else {
|
||||||
|
s.scan()
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &nmapExpr{keys, expr}
|
||||||
|
case "vmap":
|
||||||
|
var expr expr
|
||||||
|
|
||||||
|
s.scan()
|
||||||
|
keys := s.tok
|
||||||
|
|
||||||
|
s.scan()
|
||||||
|
if s.typ != tokenSemicolon {
|
||||||
|
expr = p.parseExpr()
|
||||||
|
} else {
|
||||||
|
s.scan()
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &vmapExpr{keys, expr}
|
||||||
case "cmap":
|
case "cmap":
|
||||||
var expr expr
|
var expr expr
|
||||||
|
|
||||||
|
|||||||
@@ -1,69 +1,87 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const gSixelBegin = "\033P"
|
||||||
gSixelBegin = "\033P"
|
|
||||||
|
|
||||||
// The filler character should be:
|
|
||||||
// - rarely used: the filler is used to trick tcell into redrawing, if the
|
|
||||||
// filler character appears in the user's preview, that cell might not
|
|
||||||
// be cleaned up properly
|
|
||||||
// - ideally renders as empty space: the filler alternates between bold
|
|
||||||
// and regular, using a non-space would look weird to the user.
|
|
||||||
gSixelFiller = '\u2000'
|
|
||||||
)
|
|
||||||
|
|
||||||
type sixelScreen struct {
|
type sixelScreen struct {
|
||||||
xprev, yprev int
|
lastFile string
|
||||||
sixel *string
|
lastWin win
|
||||||
altFill bool
|
forceClear bool
|
||||||
lastFile string // TODO maybe use hash of sixels instead to flip altFill
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sxs *sixelScreen) fillerStyle(filePath string) tcell.Style {
|
func (sxs *sixelScreen) clearSixel(win *win, screen tcell.Screen, filePath string) {
|
||||||
if sxs.lastFile != filePath {
|
if sxs.lastFile != "" && (filePath != sxs.lastFile || *win != sxs.lastWin || sxs.forceClear) {
|
||||||
sxs.altFill = !sxs.altFill
|
screen.LockRegion(sxs.lastWin.x, sxs.lastWin.y, sxs.lastWin.w, sxs.lastWin.h, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if sxs.altFill {
|
|
||||||
return tcell.StyleDefault.Bold(true)
|
|
||||||
}
|
|
||||||
return tcell.StyleDefault
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sxs *sixelScreen) showSixels() {
|
|
||||||
if sxs.sixel == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX: workaround for bug where quitting lf might leave the terminal in bold
|
|
||||||
fmt.Fprint(os.Stderr, "\033[0m")
|
|
||||||
|
|
||||||
fmt.Fprint(os.Stderr, "\0337") // Save cursor position
|
|
||||||
fmt.Fprintf(os.Stderr, "\033[%d;%dH", sxs.yprev, sxs.xprev) // Move cursor to position
|
|
||||||
fmt.Fprint(os.Stderr, *sxs.sixel) //
|
|
||||||
fmt.Fprint(os.Stderr, "\0338") // Restore cursor position
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sxs *sixelScreen) printSixel(win *win, screen tcell.Screen, reg *reg) {
|
func (sxs *sixelScreen) printSixel(win *win, screen tcell.Screen, reg *reg) {
|
||||||
if reg.sixel == nil {
|
if reg.path == sxs.lastFile && *win == sxs.lastWin && !sxs.forceClear {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: fillers are used to control when tcell redraws the region where a sixel image is drawn.
|
if reg.sixel == nil {
|
||||||
// alternating between bold and regular is to clear the image before drawing a new one.
|
sxs.lastFile = ""
|
||||||
st := sxs.fillerStyle(reg.path)
|
return
|
||||||
for y := range win.h {
|
|
||||||
st = win.print(screen, 0, y, st, strings.Repeat(string(gSixelFiller), win.w))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sxs.xprev, sxs.yprev = win.x+1, win.y+1
|
cw, ch, err := cellSize(screen)
|
||||||
sxs.sixel = reg.sixel
|
if err != nil {
|
||||||
|
log.Printf("sixel: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
matches := reSixelSize.FindStringSubmatch(*reg.sixel)
|
||||||
|
if matches == nil {
|
||||||
|
log.Printf("sixel: failed to get image size")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
iw, _ := strconv.Atoi(matches[1])
|
||||||
|
ih, _ := strconv.Atoi(matches[2])
|
||||||
|
|
||||||
|
if os.Getenv("TMUX") != "" {
|
||||||
|
// tmux rounds the image height up to a multiple of 6, so we
|
||||||
|
// need to do the same to avoid overwriting the image, as tmux
|
||||||
|
// would remove the image if we touched it.
|
||||||
|
ih = (ih + 5) / 6 * 6
|
||||||
|
}
|
||||||
|
|
||||||
|
screen.LockRegion(win.x, win.y, (iw+cw-1)/cw, (ih+ch-1)/ch, true)
|
||||||
|
fmt.Fprint(os.Stderr, "\0337") // Save cursor position
|
||||||
|
fmt.Fprintf(os.Stderr, "\033[%d;%dH", win.y+1, win.x+1) // Move cursor to position
|
||||||
|
fmt.Fprint(os.Stderr, *reg.sixel) // Print sixel
|
||||||
|
fmt.Fprint(os.Stderr, "\0338") // Restore cursor position
|
||||||
|
|
||||||
|
sxs.lastFile = reg.path
|
||||||
|
sxs.lastWin = *win
|
||||||
|
sxs.forceClear = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func cellSize(screen tcell.Screen) (int, int, error) {
|
||||||
|
tty, ok := screen.Tty()
|
||||||
|
if !ok {
|
||||||
|
// fallback for Windows Terminal
|
||||||
|
return 10, 20, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ws, err := tty.WindowSize()
|
||||||
|
if err != nil {
|
||||||
|
return -1, -1, fmt.Errorf("failed to get window size: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cw, ch := ws.CellDimensions()
|
||||||
|
if cw <= 0 || ch <= 0 {
|
||||||
|
return -1, -1, errors.New("cell dimensions should be greater than 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return cw, ch, nil
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -289,8 +290,10 @@ func infotimefmt(t time.Time) string {
|
|||||||
return t.Format(gOpts.infotimefmtold)
|
return t.Format(gOpts.infotimefmtold)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fileInfo(f *file, d *dir, userWidth int, groupWidth int) string {
|
func fileInfo(f *file, d *dir, userWidth int, groupWidth int, customWidth int) (string, string, int) {
|
||||||
var info strings.Builder
|
var info strings.Builder
|
||||||
|
var custom string
|
||||||
|
var off int
|
||||||
|
|
||||||
for _, s := range getInfo(d.path) {
|
for _, s := range getInfo(d.path) {
|
||||||
switch s {
|
switch s {
|
||||||
@@ -328,12 +331,18 @@ func fileInfo(f *file, d *dir, userWidth int, groupWidth int) string {
|
|||||||
fmt.Fprintf(&info, " %-*s", userWidth, userName(f.FileInfo))
|
fmt.Fprintf(&info, " %-*s", userWidth, userName(f.FileInfo))
|
||||||
case "group":
|
case "group":
|
||||||
fmt.Fprintf(&info, " %-*s", groupWidth, groupName(f.FileInfo))
|
fmt.Fprintf(&info, " %-*s", groupWidth, groupName(f.FileInfo))
|
||||||
|
case "custom":
|
||||||
|
// To allow for the usage of escape sequences, store `custom`
|
||||||
|
// separately and print it later using the offset.
|
||||||
|
off = info.Len()
|
||||||
|
fmt.Fprintf(&info, " %*s", customWidth, "")
|
||||||
|
custom = fmt.Sprintf(" %s%*s", f.customInfo, customWidth-printLength(f.customInfo), "")
|
||||||
default:
|
default:
|
||||||
log.Printf("unknown info type: %s", s)
|
log.Printf("unknown info type: %s", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return info.String()
|
return info.String(), custom, off
|
||||||
}
|
}
|
||||||
|
|
||||||
type dirContext struct {
|
type dirContext struct {
|
||||||
@@ -399,21 +408,25 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
|
|
||||||
var userWidth int
|
var userWidth int
|
||||||
var groupWidth int
|
var groupWidth int
|
||||||
|
var customWidth int
|
||||||
|
|
||||||
// Only fetch user/group widths if configured to display them
|
// Only fetch user/group/custom widths if configured to display them
|
||||||
for _, s := range getInfo(dir.path) {
|
for _, s := range getInfo(dir.path) {
|
||||||
switch s {
|
switch s {
|
||||||
case "user":
|
case "user":
|
||||||
userWidth = getUserWidth(dir, beg, end)
|
userWidth = getUserWidth(dir, beg, end)
|
||||||
case "group":
|
case "group":
|
||||||
groupWidth = getGroupWidth(dir, beg, end)
|
groupWidth = getGroupWidth(dir, beg, end)
|
||||||
|
case "custom":
|
||||||
|
customWidth = getCustomWidth(dir, beg, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
if userWidth > 0 && groupWidth > 0 {
|
if userWidth > 0 && groupWidth > 0 && customWidth > 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
visualSelections := dir.visualSelections()
|
||||||
for i, f := range dir.files[beg:end] {
|
for i, f := range dir.files[beg:end] {
|
||||||
st := dirStyle.colors.get(f)
|
st := dirStyle.colors.get(f)
|
||||||
|
|
||||||
@@ -440,7 +453,9 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
|
|
||||||
path := filepath.Join(dir.path, f.Name())
|
path := filepath.Join(dir.path, f.Name())
|
||||||
|
|
||||||
if _, ok := context.selections[path]; ok {
|
if slices.Contains(visualSelections, path) {
|
||||||
|
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.visualfmt), " ")
|
||||||
|
} else if _, ok := context.selections[path]; ok {
|
||||||
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.selectfmt), " ")
|
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.selectfmt), " ")
|
||||||
} else if cp, ok := context.saves[path]; ok {
|
} else if cp, ok := context.saves[path]; ok {
|
||||||
if cp {
|
if cp {
|
||||||
@@ -458,7 +473,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
}
|
}
|
||||||
|
|
||||||
tag := " "
|
tag := " "
|
||||||
if val, ok := context.tags[path]; ok && len(val) > 0 {
|
if val, ok := context.tags[evalSymlinks(path)]; ok && len(val) > 0 {
|
||||||
tag = val
|
tag = val
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +488,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
// subtract space for tag and icon
|
// subtract space for tag and icon
|
||||||
maxFilenameWidth := maxWidth - 1 - runeSliceWidth(icon)
|
maxFilenameWidth := maxWidth - 1 - runeSliceWidth(icon)
|
||||||
|
|
||||||
info := fileInfo(f, dir, userWidth, groupWidth)
|
info, custom, off := fileInfo(f, dir, userWidth, groupWidth, customWidth)
|
||||||
infolen := len(info)
|
infolen := len(info)
|
||||||
showInfo := infolen > 0 && 2*infolen < maxWidth
|
showInfo := infolen > 0 && 2*infolen < maxWidth
|
||||||
if showInfo {
|
if showInfo {
|
||||||
@@ -494,6 +509,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
|
|
||||||
if showInfo {
|
if showInfo {
|
||||||
filename = append(filename, []rune(info)...)
|
filename = append(filename, []rune(info)...)
|
||||||
|
off += lnwidth + 2 + runeSliceWidth(icon) + maxFilenameWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
if i == dir.pos {
|
if i == dir.pos {
|
||||||
@@ -513,6 +529,11 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
line := append(icon, filename...)
|
line := append(icon, filename...)
|
||||||
line = append(line, ' ')
|
line = append(line, ' ')
|
||||||
win.print(ui.screen, lnwidth+2, i, st, fmt.Sprintf(cursorFmt, string(line)))
|
win.print(ui.screen, lnwidth+2, i, st, fmt.Sprintf(cursorFmt, string(line)))
|
||||||
|
|
||||||
|
// print over the empty space we reserved for the custom info
|
||||||
|
if showInfo && custom != "" {
|
||||||
|
win.print(ui.screen, off, i, st, fmt.Sprintf(cursorFmt, stripAnsi(custom)))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if tag == " " {
|
if tag == " " {
|
||||||
win.print(ui.screen, lnwidth+1, i, st, " ")
|
win.print(ui.screen, lnwidth+1, i, st, " ")
|
||||||
@@ -531,6 +552,11 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
|
|
||||||
line := append(filename, ' ')
|
line := append(filename, ' ')
|
||||||
win.print(ui.screen, lnwidth+2+runeSliceWidth(icon), i, st, string(line))
|
win.print(ui.screen, lnwidth+2+runeSliceWidth(icon), i, st, string(line))
|
||||||
|
|
||||||
|
// print over the empty space we reserved for the custom info
|
||||||
|
if showInfo && custom != "" {
|
||||||
|
win.print(ui.screen, off, i, st, custom)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -555,6 +581,16 @@ func getGroupWidth(dir *dir, beg int, end int) int {
|
|||||||
return maxw
|
return maxw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCustomWidth(dir *dir, beg int, end int) int {
|
||||||
|
maxw := 0
|
||||||
|
|
||||||
|
for _, f := range dir.files[beg:end] {
|
||||||
|
maxw = max(printLength(f.customInfo), maxw)
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxw
|
||||||
|
}
|
||||||
|
|
||||||
func getWidths(wtot int) []int {
|
func getWidths(wtot int) []int {
|
||||||
rsum := 0
|
rsum := 0
|
||||||
for _, r := range gOpts.ratios {
|
for _, r := range gOpts.ratios {
|
||||||
@@ -788,6 +824,13 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
|||||||
}
|
}
|
||||||
statfmt = strings.ReplaceAll(statfmt, s, val)
|
statfmt = strings.ReplaceAll(statfmt, s, val)
|
||||||
}
|
}
|
||||||
|
if nav.isVisualMode() {
|
||||||
|
replace("%m", "VISUAL")
|
||||||
|
replace("%M", "VISUAL")
|
||||||
|
} else {
|
||||||
|
replace("%m", "")
|
||||||
|
replace("%M", "NORMAL")
|
||||||
|
}
|
||||||
replace("%p", curr.Mode().String())
|
replace("%p", curr.Mode().String())
|
||||||
replace("%c", linkCount(curr))
|
replace("%c", linkCount(curr))
|
||||||
replace("%u", userName(curr))
|
replace("%u", userName(curr))
|
||||||
@@ -892,6 +935,19 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
hid := len(dir.allFiles) - tot
|
hid := len(dir.allFiles) - tot
|
||||||
acc := string(ui.keyCount) + string(ui.keyAcc)
|
acc := string(ui.keyCount) + string(ui.keyAcc)
|
||||||
|
|
||||||
|
var percentage string
|
||||||
|
beg := max(dir.ind-dir.pos, 0)
|
||||||
|
switch {
|
||||||
|
case tot <= nav.height:
|
||||||
|
percentage = "All"
|
||||||
|
case beg == 0:
|
||||||
|
percentage = "Top"
|
||||||
|
case beg == tot-nav.height:
|
||||||
|
percentage = "Bot"
|
||||||
|
default:
|
||||||
|
percentage = fmt.Sprintf("%2d%%", beg*100/(tot-nav.height))
|
||||||
|
}
|
||||||
|
|
||||||
copy := 0
|
copy := 0
|
||||||
move := 0
|
move := 0
|
||||||
for _, cp := range nav.saves {
|
for _, cp := range nav.saves {
|
||||||
@@ -903,12 +959,12 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
currSelections := nav.currSelections()
|
currSelections := nav.currSelections()
|
||||||
|
currVSelections := nav.currDir().visualSelections()
|
||||||
|
|
||||||
progress := []string{}
|
progress := []string{}
|
||||||
|
|
||||||
if nav.copyTotal > 0 {
|
if nav.copyTotal > 0 {
|
||||||
percentage := int((100 * float64(nav.copyBytes)) / float64(nav.copyTotal))
|
progress = append(progress, fmt.Sprintf("[%d%%]", nav.copyBytes*100/nav.copyTotal))
|
||||||
progress = append(progress, fmt.Sprintf("[%d%%]", percentage))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if nav.moveTotal > 0 {
|
if nav.moveTotal > 0 {
|
||||||
@@ -935,6 +991,8 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
result = fmt.Sprintf("%.d", copy)
|
result = fmt.Sprintf("%.d", copy)
|
||||||
case "%s":
|
case "%s":
|
||||||
result = fmt.Sprintf("%.d", len(currSelections))
|
result = fmt.Sprintf("%.d", len(currSelections))
|
||||||
|
case "%v":
|
||||||
|
result = fmt.Sprintf("%.d", len(currVSelections))
|
||||||
case "%f":
|
case "%f":
|
||||||
result = strings.Join(dir.filter, " ")
|
result = strings.Join(dir.filter, " ")
|
||||||
case "%i":
|
case "%i":
|
||||||
@@ -943,6 +1001,8 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
result = strconv.Itoa(tot)
|
result = strconv.Itoa(tot)
|
||||||
case "%h":
|
case "%h":
|
||||||
result = strconv.Itoa(hid)
|
result = strconv.Itoa(hid)
|
||||||
|
case "%P":
|
||||||
|
result = percentage
|
||||||
case "%d":
|
case "%d":
|
||||||
result = diskFree(dir.path)
|
result = diskFree(dir.path)
|
||||||
default:
|
default:
|
||||||
@@ -1020,7 +1080,6 @@ func (ui *ui) draw(nav *nav) {
|
|||||||
context := dirContext{selections: nav.selections, saves: nav.saves, tags: nav.tags}
|
context := dirContext{selections: nav.selections, saves: nav.saves, tags: nav.tags}
|
||||||
|
|
||||||
ui.screen.Clear()
|
ui.screen.Clear()
|
||||||
ui.sxScreen.sixel = nil
|
|
||||||
|
|
||||||
ui.drawPromptLine(nav)
|
ui.drawPromptLine(nav)
|
||||||
|
|
||||||
@@ -1058,14 +1117,15 @@ func (ui *ui) draw(nav *nav) {
|
|||||||
ui.screen.ShowCursor(ui.msgWin.x+runeSliceWidth(prefix)+runeSliceWidth(left), ui.msgWin.y)
|
ui.screen.ShowCursor(ui.msgWin.x+runeSliceWidth(prefix)+runeSliceWidth(left), ui.msgWin.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
if gOpts.preview {
|
|
||||||
curr, err := nav.currFile()
|
curr, err := nav.currFile()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
preview := ui.wins[len(ui.wins)-1]
|
preview := ui.wins[len(ui.wins)-1]
|
||||||
|
ui.sxScreen.clearSixel(preview, ui.screen, curr.path)
|
||||||
|
if gOpts.preview {
|
||||||
if curr.Mode().IsRegular() || (curr.IsDir() && gOpts.dirpreviews) {
|
if curr.Mode().IsRegular() || (curr.IsDir() && gOpts.dirpreviews) {
|
||||||
preview.printReg(ui.screen, ui.regPrev, nav.previewLoading, &ui.sxScreen)
|
preview.printReg(ui.screen, ui.regPrev, nav.previewLoading, &ui.sxScreen)
|
||||||
} else if curr.IsDir() {
|
} else if curr.IsDir() {
|
||||||
|
ui.sxScreen.lastFile = ""
|
||||||
preview.printDir(ui, ui.dirPrev, &context,
|
preview.printDir(ui, ui.dirPrev, &context,
|
||||||
&dirStyle{colors: ui.styles, icons: ui.icons, role: Preview})
|
&dirStyle{colors: ui.styles, icons: ui.icons, role: Preview})
|
||||||
}
|
}
|
||||||
@@ -1097,10 +1157,6 @@ func (ui *ui) draw(nav *nav) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui.screen.Show()
|
ui.screen.Show()
|
||||||
if ui.menu == "" && ui.cmdPrefix == "" && ui.sxScreen.sixel != nil {
|
|
||||||
ui.sxScreen.lastFile = ui.regPrev.path
|
|
||||||
ui.sxScreen.showSixels()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func findBinds(keys map[string]expr, prefix string) (binds map[string]expr, ok bool) {
|
func findBinds(keys map[string]expr, prefix string) (binds map[string]expr, ok bool) {
|
||||||
@@ -1117,32 +1173,68 @@ func findBinds(keys map[string]expr, prefix string) (binds map[string]expr, ok b
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func listExprMap(binds map[string]expr, title string) string {
|
func listBinds(binds map[string]map[string]expr) string {
|
||||||
t := new(tabwriter.Writer)
|
t := new(tabwriter.Writer)
|
||||||
b := new(bytes.Buffer)
|
b := new(bytes.Buffer)
|
||||||
|
|
||||||
keys := make([]string, 0, len(binds))
|
m := make(map[string]map[string]string)
|
||||||
for k := range binds {
|
for mode, keys := range binds {
|
||||||
keys = append(keys, k)
|
for key, expr := range keys {
|
||||||
|
if _, ok := m[key]; !ok {
|
||||||
|
m[key] = make(map[string]string)
|
||||||
}
|
}
|
||||||
sort.Strings(keys)
|
m[key][expr.String()] += mode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type entry struct {
|
||||||
|
mode, key, cmd string
|
||||||
|
}
|
||||||
|
|
||||||
|
var entries []entry
|
||||||
|
for key, cmds := range m {
|
||||||
|
for cmd, modes := range cmds {
|
||||||
|
tmp := []rune(modes)
|
||||||
|
slices.Sort(tmp)
|
||||||
|
entries = append(entries, entry{string(tmp), key, cmd})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(entries, func(i, j int) bool {
|
||||||
|
if entries[i].key != entries[j].key {
|
||||||
|
return entries[i].key < entries[j].key
|
||||||
|
}
|
||||||
|
return entries[i].mode < entries[j].mode
|
||||||
|
})
|
||||||
|
|
||||||
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
|
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
|
||||||
fmt.Fprintf(t, "%s\tcommand\n", title)
|
fmt.Fprintln(t, "mode\tkeys\tcommand")
|
||||||
for _, k := range keys {
|
for _, e := range entries {
|
||||||
fmt.Fprintf(t, "%s\t%v\n", k, binds[k])
|
fmt.Fprintf(t, "%s\t%s\t%s\n", e.mode, e.key, e.cmd)
|
||||||
}
|
}
|
||||||
t.Flush()
|
t.Flush()
|
||||||
|
|
||||||
return b.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func listBinds(binds map[string]expr) string {
|
func listCmds(cmds map[string]expr) string {
|
||||||
return listExprMap(binds, "keys")
|
t := new(tabwriter.Writer)
|
||||||
}
|
b := new(bytes.Buffer)
|
||||||
|
|
||||||
func listCmds() string {
|
keys := make([]string, 0, len(cmds))
|
||||||
return listExprMap(gOpts.cmds, "name")
|
for k := range cmds {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
|
||||||
|
fmt.Fprintln(t, "name\tcommand")
|
||||||
|
for _, k := range keys {
|
||||||
|
fmt.Fprintf(t, "%s\t%v\n", k, cmds[k])
|
||||||
|
}
|
||||||
|
t.Flush()
|
||||||
|
|
||||||
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func listJumps(jumps []string, ind int) string {
|
func listJumps(jumps []string, ind int) string {
|
||||||
@@ -1295,6 +1387,13 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
draw := &callExpr{"draw", nil, 1}
|
draw := &callExpr{"draw", nil, 1}
|
||||||
count := 0
|
count := 0
|
||||||
|
|
||||||
|
keys := gOpts.nkeys
|
||||||
|
mode := "n"
|
||||||
|
if nav.isVisualMode() {
|
||||||
|
keys = gOpts.vkeys
|
||||||
|
mode = "v"
|
||||||
|
}
|
||||||
|
|
||||||
switch tev := ev.(type) {
|
switch tev := ev.(type) {
|
||||||
case *tcell.EventKey:
|
case *tcell.EventKey:
|
||||||
// KeyRune is a regular character
|
// KeyRune is a regular character
|
||||||
@@ -1329,7 +1428,7 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
return draw
|
return draw
|
||||||
}
|
}
|
||||||
|
|
||||||
binds, ok := findBinds(gOpts.keys, string(ui.keyAcc))
|
binds, ok := findBinds(keys, string(ui.keyAcc))
|
||||||
|
|
||||||
switch len(binds) {
|
switch len(binds) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -1347,7 +1446,7 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
}
|
}
|
||||||
count = c
|
count = c
|
||||||
}
|
}
|
||||||
expr := gOpts.keys[string(ui.keyAcc)]
|
expr := keys[string(ui.keyAcc)]
|
||||||
|
|
||||||
if count != 0 {
|
if count != 0 {
|
||||||
switch e := expr.(type) {
|
switch e := expr.(type) {
|
||||||
@@ -1364,7 +1463,9 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
return expr
|
return expr
|
||||||
}
|
}
|
||||||
if gOpts.showbinds {
|
if gOpts.showbinds {
|
||||||
ui.menu = listBinds(binds)
|
ui.menu = listBinds(map[string]map[string]expr{
|
||||||
|
mode: binds,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return draw
|
return draw
|
||||||
}
|
}
|
||||||
@@ -1406,7 +1507,7 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
if tev.Modifiers() == tcell.ModCtrl {
|
if tev.Modifiers() == tcell.ModCtrl {
|
||||||
button = "<c-" + button[1:]
|
button = "<c-" + button[1:]
|
||||||
}
|
}
|
||||||
if expr, ok := gOpts.keys[button]; ok {
|
if expr, ok := keys[button]; ok {
|
||||||
return expr
|
return expr
|
||||||
}
|
}
|
||||||
if button != "<m-1>" && button != "<m-2>" {
|
if button != "<m-1>" && button != "<m-2>" {
|
||||||
@@ -1522,6 +1623,7 @@ func (ui *ui) readExpr() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) suspend() error {
|
func (ui *ui) suspend() error {
|
||||||
|
ui.sxScreen.forceClear = true
|
||||||
return ui.screen.Suspend()
|
return ui.screen.Suspend()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1534,43 +1636,6 @@ func (ui *ui) resume() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) exportMode() {
|
|
||||||
getMode := func() string {
|
|
||||||
if strings.HasPrefix(ui.cmdPrefix, "delete") {
|
|
||||||
return "delete"
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(ui.cmdPrefix, "replace") || strings.HasPrefix(ui.cmdPrefix, "create") {
|
|
||||||
return "rename"
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ui.cmdPrefix {
|
|
||||||
case "filter: ":
|
|
||||||
return "filter"
|
|
||||||
case "find: ", "find-back: ":
|
|
||||||
return "find"
|
|
||||||
case "mark-save: ", "mark-load: ", "mark-remove: ":
|
|
||||||
return "mark"
|
|
||||||
case "rename: ":
|
|
||||||
return "rename"
|
|
||||||
case "/", "?":
|
|
||||||
return "search"
|
|
||||||
case ":":
|
|
||||||
return "command"
|
|
||||||
case "$", "%", "!", "&":
|
|
||||||
return "shell"
|
|
||||||
case ">":
|
|
||||||
return "pipe"
|
|
||||||
case "":
|
|
||||||
return "normal"
|
|
||||||
default:
|
|
||||||
return "unknown"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
os.Setenv("lf_mode", getMode())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ui *ui) exportSizes() {
|
func (ui *ui) exportSizes() {
|
||||||
w, h := ui.screen.Size()
|
w, h := ui.screen.Size()
|
||||||
os.Setenv("lf_width", strconv.Itoa(w))
|
os.Setenv("lf_width", strconv.Itoa(w))
|
||||||
|
|||||||
@@ -96,6 +96,14 @@ func (watch *watch) loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ev.Has(fsnotify.Write) || ev.Has(fsnotify.Chmod) {
|
if ev.Has(fsnotify.Write) || ev.Has(fsnotify.Chmod) {
|
||||||
|
// skip write updates for the log file, otherwise it is possible
|
||||||
|
// to have an infinite loop where writing to the log file causes
|
||||||
|
// it to be reloaded, which in turn triggers more events that
|
||||||
|
// are then logged
|
||||||
|
if ev.Name == gLogPath && ev.Has(fsnotify.Write) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
dir, file := filepath.Split(ev.Name)
|
dir, file := filepath.Split(ev.Name)
|
||||||
for _, path := range watch.getSameDirs(dir) {
|
for _, path := range watch.getSameDirs(dir) {
|
||||||
watch.addUpdate(filepath.Join(path, file))
|
watch.addUpdate(filepath.Join(path, file))
|
||||||
|
|||||||
Reference in new issue
Block a user