Skip to main content
  1. Lumesh Cases/
  2. Lumesh Cases -- lf/

lf File Manager Configuration Comparison D

1164 words·6 mins
Table of Contents

lf File Manager Configuration Comparison D
#

31. rename-to Command
#

Key Binding: mv

Code Comparison:

  • Lumesh: Uses built-in file functions and string interpolation
1let base_name = Fs.base_name($fx)
2let new_name = read `rename "$base_name" to:`
3if $new_name {
4    $lf_user_wheel mv -- $base_name $new_name
5    lf -remote `send $id :select $new_name`
6}
  • Bash: Uses basename and printf
1fn=$(basename "$fx")
2printf "rename $fn to:"
3read ans
4[ -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
1let ans = read "Mode Bits:"
2if $ans {
3    $fx |> $lf_user_wheel chmod $ans _
4    lf -remote 'send reload'
5}
  • Bash: Uses xargs for parallel processing
1printf "\nMode Bits: "
2read ans
3if [ -n "$ans" ]; then
4    set -f
5    printf "%s\n" $fx | xargs -P 4 -i $lf_user_wheel chmod $ans {}
6    lf -remote 'send reload'
7fi

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
1let ans = read "new Owner:Group :"
2if $ans {
3    $fx |> $lf_user_wheel chown $argv $ans -- _
4    lf -remote 'send reload'
5}
  • Bash: Uses traditional for loop
 1printf "\nnew Owner:Group : "
 2read ans
 3if [ -n "$ans" ]; then
 4    set -f
 5    for file in "$fx"
 6    do
 7        $lf_user_wheel chown $@ $ans $file
 8    done
 9    lf -remote 'send reload'
10fi

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
1if len($argv) > 0 {
2    $lf_user_wheel touch -- $argv
3    for file in $argv {
4        lf -remote `send $id select $file; tag '+'`
5    }
6}
  • Bash: Uses parameter checks
1if [ -n "$@" ]; then
2    $lf_user_wheel touch -- "$@"
3    lf -remote "send $id select $@"
4fi

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
 1if $argv {
 2    $lf_user_wheel mkdir -p -- $argv
 3    let name = ""
 4    for file in $argv {
 5        if !$file.starts_with('/') {
 6            name = Fs.base_name($file)
 7            lf -remote `send $id :select $name; tag '+'`
 8        }
 9    }
10}
  • Bash: Uses cut command to extract directory names
1set -f
2$lf_user_wheel mkdir -p -- "$@"
3for file in "$@"; do
4    lf -remote "send $id :select $(echo $file | cut -d'/' -f1); tag +"
5done

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
 1let dest = read "Fold to :"
 2if $dest {
 3    if Fs.exists($dest) {
 4        eprint 'Dest already Exists'
 5        exit 0
 6    }
 7    $lf_user_wheel mkdir -- $dest
 8    let files = $fx | .lines()
 9    $lf_user_wheel mv -- $files $dest
10    lf -remote `send $id select '$dest'`
11}
  • Bash: Uses printf and traditional tools
1set -f
2printf "Directory name: "
3read newd
4$lf_user_wheel mkdir -- "$newd"
5$lf_user_wheel mv -- $fx "$newd"
6lf -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
1&geany $fx
2&code $fx
3&lapce $fx
  • Bash: Uses quotes for protection
1&geany "$fx"
2&code "$fx"
3&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
1&$lf_user_wheel foot lf '.'
2&thunar '.'
3&hx '.'
  • Bash: Also uses string literals
1&$lf_user_wheel foot lf .
2&thunar .
3&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
1&$argv[0] $fx    ## GUI app
2$$argv[0] $fx    ## CLI app
  • Bash: Uses positional parameters
1&$@ $fx    ## GUI app
2$$@ $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
1let base_name = Fs.base_name($f)
2let mntdir=`/tmp/lf/mount/$base_name`
3mkdir -p $mntdir
4$lf_user_wheel archivemount $f $mntdir -o nosave
5lf -remote `send $id cd $mntdir`
  • Bash: Uses command substitution
1mntdir="/tmp/lf/mount/$(basename $f).mnt"
2mkdir -p "$mntdir"
3$lf_user_wheel archivemount "$f" "$mntdir" -o nosave
4lf -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 FeatureLumeshBashModernization Level
Conditional Expressioncondition ? value : default`[ condition ] && value
String Methods.starts_with(), .ends_with()grep, testLumesh is more intuitive
File OperationsFs.base_name(), Fs.exists()basename, test -eLumesh is type-safe
Array Handling.lines(), .map()awk, cut, sedLumesh is functional
Error Handling?:, ?.&&, `

Performance and Resource Usage
#

AspectLumeshBash
Startup Speed7.40ms (lume version, includes repl and built-in libraries)4.78ms
6.60ms (lumesh version, includes built-in libraries, excludes repl)
Memory Usage6MB8MB
Tool DependenciesBuilt-in rich functionalityRelies 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:

Related