lf File Manager Configuration Comparison D

wiki case

lf File Manager Configuration Comparison D

31. rename-to Command

Key Binding: mv

Code Comparison:

  • Lumesh: Uses built-in file functions and string interpolation
let base_name = Fs.base_name($fx)
let new_name = read `rename "$base_name" to:`
if $new_name {
$lf_user_wheel mv -- $base_name $new_name
lf -remote `send $id :select $new_name`
}
  • Bash: Uses basename and printf
fn=$(basename "$fx")
printf "rename $fn to:"
read ans
[ -n "$ans" ] && $lf_user_wheel mv -- $fn $ans

Advantages:

  • Lumesh: Built-in file functions are type-safe, string interpolation is more intuitive
  • Bash: Basename command is standard, conditional checks are concise

32. chmod Command

Key Binding: cm

Code Comparison:

  • Lumesh: Uses pipeline operator and loops
let ans = read "Mode Bits:"
if $ans {
$fx |> $lf_user_wheel chmod $ans _
lf -remote 'send reload'
}
  • Bash: Uses xargs for parallel processing
printf "\nMode Bits: "
read ans
if [ -n "$ans" ]; then
set -f
printf "%s\n" $fx | xargs -P 4 -i $lf_user_wheel chmod $ans {}
lf -remote 'send reload'
fi

Advantages:

  • Lumesh: Pipeline operator |> has modern syntax, loop processing is intuitive
  • Bash: xargs provides better performance for parallel processing, -P 4 supports multiple processes

33. chown Command

Key Binding: co, cO (recursive)

Code Comparison:

  • Lumesh: Uses pipeline operator
let ans = read "new Owner:Group :"
if $ans {
$fx |> $lf_user_wheel chown $argv $ans -- _
lf -remote 'send reload'
}
  • Bash: Uses traditional for loop
printf "\nnew Owner:Group : "
read ans
if [ -n "$ans" ]; then
set -f
for file in "$fx"
do
$lf_user_wheel chown $@ $ans $file
done
lf -remote 'send reload'
fi

Advantages:

  • Lumesh: Unified handling with pipeline operator, good syntax consistency
  • Bash: For loop provides precise control, error handling is more granular

34. mkfile Command

Key Binding: mf

Code Comparison:

  • Lumesh: Uses conditional checks and loops
if len($argv) > 0 {
$lf_user_wheel touch -- $argv
for file in $argv {
lf -remote `send $id select $file; tag '+'`
}
}
  • Bash: Uses parameter checks
if [ -n "$@" ]; then
$lf_user_wheel touch -- "$@"
lf -remote "send $id select $@"
fi

Advantages:

  • Lumesh: len() function is clear in semantics, loops process each file
  • Bash: Parameter checks are concise, batch selection is efficient

35. mkdirs Command

Key Binding: mk

Code Comparison:

  • Lumesh: Uses string methods and conditional checks
if $argv {
$lf_user_wheel mkdir -p -- $argv
let name = ""
for file in $argv {
if !$file.starts_with('/') {
name = Fs.base_name($file)
lf -remote `send $id :select $name; tag '+'`
}
}
}
  • Bash: Uses cut command to extract directory names
set -f
$lf_user_wheel mkdir -p -- "$@"
for file in "$@"; do
lf -remote "send $id :select $(echo $file | cut -d'/' -f1); tag +"
done

Advantages:

  • Lumesh: String method .starts_with() is intuitive, path handling is type-safe
  • Bash: Cut command efficiently handles path splitting, set -f disables wildcard expansion for safety

36. folder-selected Command

Key Binding: ms

Code Comparison:

  • Lumesh: Uses built-in functions and error checks
let dest = read "Fold to :"
if $dest {
if Fs.exists($dest) {
eprint 'Dest already Exists'
exit 0
}
$lf_user_wheel mkdir -- $dest
let files = $fx | .lines()
$lf_user_wheel mv -- $files $dest
lf -remote `send $id select '$dest'`
}
  • Bash: Uses printf and traditional tools
set -f
printf "Directory name: "
read newd
$lf_user_wheel mkdir -- "$newd"
$lf_user_wheel mv -- $fx "$newd"
lf -remote "send $id select \"$newd\""

Advantages:

  • Lumesh: Built-in existence checks provide better error handling
  • Bash: Directly creates directories, making the process simpler

37. Editor Launch Commands

Key Binding: En (geany), Ec (code), Ep (lapce), Eg (geany), Ee (gedit), Ea (apostrophe), El (lite-xl), Em (marker), Er (retext), Ev (vi), Ez (zed)

Code Comparison:

  • Lumesh: Directly uses variables
&geany $fx
&code $fx
&lapce $fx
  • Bash: Uses quotes for protection
&geany "$fx"
&code "$fx"
&lapce "$fx"

Advantages:

  • Lumesh: Variable expansion automatically handles spaces
  • Bash: Quoting protects against parameter splitting, making it safer

38. Terminal Launch Commands

Key Binding: rr (foot lf), rt (thunar), rs (spacefm), rh (hx), rc (code), rp (lapce), rn (geany), rl (lite-xl), rz (zed)

Code Comparison:

  • Lumesh: Uses string literals
&$lf_user_wheel foot lf '.'
&thunar '.'
&hx '.'
  • Bash: Also uses string literals
&$lf_user_wheel foot lf .
&thunar .
&hx .

Advantages:

  • Both versions are essentially the same, involving simple command calls

39. open-with-gui/cli Command

Key Binding: Og (GUI app), Oc (CLI app)

Code Comparison:

  • Lumesh: Uses array indexing
&$argv[0] $fx    ## GUI app
$$argv[0] $fx ## CLI app
  • Bash: Uses positional parameters
&$@ $fx    ## GUI app
$$@ $fx ## CLI app

Advantages:

  • Lumesh: Array indexing clearly specifies the first parameter
  • Bash: Positional parameter $@ expands all parameters, providing more flexibility

40. archive-mount Command

Key Binding: am

Code Comparison:

  • Lumesh: Uses string interpolation and built-in functions
let base_name = Fs.base_name($f)
let mntdir=`/tmp/lf/mount/$base_name`
mkdir -p $mntdir
$lf_user_wheel archivemount $f $mntdir -o nosave
lf -remote `send $id cd $mntdir`
  • Bash: Uses command substitution
mntdir="/tmp/lf/mount/$(basename $f).mnt"
mkdir -p "$mntdir"
$lf_user_wheel archivemount "$f" "$mntdir" -o nosave
lf -remote "send $id cd $mntdir"

Advantages:

  • Lumesh: Built-in file functions are type-safe, string interpolation is clear
  • Bash: Basename command is standard, adding .mnt suffix avoids conflicts

Final Comparison Summary

Syntax Modernization Level

Syntax Feature Lumesh Bash Modernization Level
Conditional Expression condition ? value : default `[ condition ] && value
String Methods .starts_with(), .ends_with() grep, test Lumesh is more intuitive
File Operations Fs.base_name(), Fs.exists() basename, test -e Lumesh is type-safe
Array Handling .lines(), .map() awk, cut, sed Lumesh is functional
Error Handling ?:, ?. &&, `

Performance and Resource Usage

Aspect Lumesh Bash
Startup Speed 7.40ms (lume version, includes repl and built-in libraries) 4.78ms
6.60ms (lumesh version, includes built-in libraries, excludes repl)
Memory Usage 6MB 8MB
Tool Dependencies Built-in rich functionality Relies on system tools

Maintainability and Readability

Lumesh Advantages:

  • Unified API design and naming conventions
  • Type safety reduces runtime errors
  • Modern syntax improves code readability
  • Built-in error handling mechanisms

Bash Advantages:

  • Mature ecosystem and toolchain
  • Extensive community support and documentation
  • Standardized error handling patterns
  • Excellent cross-platform compatibility

Notes

Through the complete comparative analysis of all lf configuration commands, it is evident that:

  1. Functional Equivalence: Both implementations can accomplish the same file management tasks, with identical key bindings.
  2. Syntax Differences: Lumesh reflects the design philosophy of modern shell languages, while Bash maintains traditional Unix principles.
  3. Selection Recommendations:
    • Choose Lumesh: If you prioritize modern syntax, type safety, and code readability.
    • Choose Bash: If you focus on compatibility, performance, and a mature tool ecosystem.

Both implementations are excellent lf configuration options, and the choice primarily depends on the user’s technology stack preferences and specific needs.

Wiki pages you might want to explore: