Comparison of lf File Manager Configurations A
The lumesh version uses modern syntax and built-in functions, while the bash version employs traditional shell syntax and external tools.
Overview
General Function Commands
all-cmd
,history-cmd
,history-dir
- Command history and selectiontoggle-preview
,toggle-selmode
,toggle-super
- Interface toggleszox/z
,zoxide-query
,cd-usermedia
- Directory navigation
File Operation Commands
select-files
series - File selection and filteringyank-path
,yank-name
,yank-basename
- Copy operationsdelete
,trash
,paste/mpaste
,link
- File managementrename-to
,bulk-rename
- Renaming operationschmod
,chown
,mkfile
,mkdirs
- Permissions and creation
Search and Preview Commands
fzf-edit
,fzf-file
,fzf-folder
,fzf-content
- Fuzzy searchfilter
series - File filtering
Compression and Mounting Commands
extract-to
,compress-to
,archive-mount
- Archive handlingmount-dev
,umount-dev
- Device mounting
Comparison and Verification Commands
diff
,delta
,diff-md5
,check-sum
- File comparison
External Integration
cmus-play
,open-handlr
,open-with-gui/cli
- Program launchingdrag-in
,drag-out
- Drag-and-drop operations- Editor launch commands (
En
,Ec
,Ep
, etc.)
System Commands
on-cd
- Automatically triggered commands
Both implementations are functionally equivalent, with identical key bindings. The choice mainly depends on the user’s preference for modern syntax versus reliance on traditional Unix tools.
Enabling Shell in lf
- To enable Lumesh in lf:
set shell lumesh # Required |
- To enable bash in lf:
set shell bash # Required |
Main Command Comparison A
1. all-cmd Command
Key Binding: <c-e>
Syntax Comparison:
- lumesh: Uses a chained pipeline method and built-in functions
let cmd = lf -remote `query $id cmds` | .lines() | .sort() | .drop(1) | .map(x -> {x.split("\t\t") | .first()}) | Ui.pick "select cmd:" |
- bash: Uses pipelines and external tools
cmd=$( lf -remote "query $id cmds" | awk -F'\t' 'NR > 1 { print $NF}' | sort -u | fzf --reverse --prompt='Execute command: ' --preview='' ) |
Advantages:
- lumesh: More intuitive syntax, readable chained calls, eliminates external application startup and data conversion time, built-in
Ui.pick
provides a unified interaction experience. - bash: Uses standard Unix tools, good compatibility,
awk
offers more flexible text processing.
2. history-cmd Command
Key Binding: <backspace>
, <backspace2>
Syntax Comparison:
- lumesh:
let cmd = lf -remote `query $id history` | .lines() | .sort() | Ui.pick "history command:" | .split("\t\t") | .last() |
- bash:
cmd=$( lf -remote "query $id history" | awk -F'\t' 'NR > 1 { print $NF}' | sort -u | fzf --reverse --prompt='Execute command: ' --preview='' ) |
Advantages:
- lumesh: Built-in method chain is more concise,
.last()
is semantically clear. - bash:
awk
‘s$NF
efficiently handles the last column.
3. toggle-preview Command
Key Binding: zp
Syntax Comparison:
- lumesh: Uses pattern matching
match $lf_preview { |
- bash: Uses conditional statements
if [ "$lf_preview" = "true" ]; then |
Advantages:
- lumesh:
match
syntax is more modern, powerful pattern matching; variables do not require quotes. - bash: Traditional
if-else
structure is clear and easy to debug.
4. select-files Command
Key Binding: Sf
(files), Sd
(directories), SF
(empty files), SD
(empty directories), Sl
(symbolic links), Sx
(executable files)
Syntax Comparison:
- lumesh: Uses a ternary operator and built-in functions
let htag= $lf_hidden ? '-H' : '' |
- bash: Uses functions and conditional statements
get_files() { |
Advantages:
- lumesh: Ternary operator is concise, variable scope is clear.
- bash: Function encapsulation provides clear logic and good reusability.
5. fzf-content Command
Key Binding: fc<space>
, fct
(txt), fcm
(md), fcs
(sh), fcy
(py), fcj
(js)
Syntax Comparison:
- lumesh: Uses modern syntax and string interpolation
let file_type = len($argv)>0 ? $argv[0] : 'sh' |
- bash: Uses traditional shell syntax
RG_PREFIX="$lf_user_wheel rg --column --line-number --no-heading --color=always --smart-case --max-filesize 50K" |
Advantages:
- lumesh: String method chaining is more intuitive, conditional expressions are concise.
- bash: Parameter expansion is flexible,
cut
command efficiently handles delimiters.
6. yank Series Commands
Key Binding: yp
(path), yn
(filename), yb
(basename), yu
(clear)
Syntax Comparison:
- lumesh: Uses functional programming style
$fx.lines() | .map(Fs.base_name) | .join("\n") | wl-copy |
- bash: Uses traditional Unix tools
basename -a -- "$fx" | head -c-1 | wl-copy |
Advantages:
- lumesh: Consistent functional style, rich built-in filesystem functions.
- bash: Mature and stable Unix tools,
basename
,cut
, etc., are professional and efficient.
7. paste/mpaste Command
Key Binding: pp
(paste), po
(force), pb
(backup), pO
(force overwrite)
Syntax Comparison:
- lumesh: Uses modern collection operations
let load=Fs.read ~/.local/share/lf/files | .lines() |
- bash: Uses traditional text processing
load=$(cat ~/.local/share/lf/files) |
Advantages:
- lumesh: Collection operations are intuitive, pattern matching is elegant, built-in file functions are type-safe.
- bash: Powerful text processing with
sed
, clear conditional branches.
8. bulk-rename Command
Key Binding: cb
Syntax Comparison:
- lumesh: Uses modern data structures
let old_files = $fs.lines() |
- bash: Uses traditional text processing
paste "$old" "$new" | while IFS= read -r names; do |
Advantages:
- lumesh:
List.zip
functional operation is elegant, array access is intuitive. - bash:
paste
command is professional, pipeline processing is memory efficient.
9. mount-dev Command
Key Binding: mm
Syntax Comparison:
- lumesh: Uses structured data processing
let sel = lsblk -rno 'name,type,size,mountpoint,label,fstype' | Into.table([name,'type',size,mountpoint,label,fstype]) |
- bash: Uses text processing and field extraction
sel=$(lsblk -rno 'name,type,size,label,mountpoint,fstype' | |
Advantages:
- lumesh: Powerful structured data processing, type-safe field access, intuitive
where
filtering. - bash: Flexible and efficient text processing with
awk
, mature and stable field extraction.
Overall Advantages Comparison
Advantages of Lumesh:
- Modern syntax, intuitive chained calls
- Rich built-in functions, type-safe
- Consistent functional programming style
- Strong structured data processing capabilities
- Improved debugging and error handling mechanisms
- Minimizes reliance on third-party tools, saving resources
Advantages of Bash:
- Mature Unix tool ecosystem
- Good compatibility and portability
- Professional and efficient third-party text processing tools
Notes
Both implementations achieve the same functionality of the lf file manager, with identical key bindings. The Lumesh version showcases the advantages of modern shell languages, while the bash version reflects the stability of traditional Unix philosophy. The choice primarily depends on the user’s preference for syntax style and reliance on tool ecosystems.
Read more