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

lf File Manager Configuration Comparison C

1350 words·7 mins
Table of Contents

lf File Manager Configuration Comparison C
#

18. profile Command
#

Key Binding: z2 (extra), z3 (disk), z4 (convert), z5 (develop), z6 (auto-redraw), z7 (tarzip)

Code Comparison:

  • Lumesh: Uses string interpolation and array access
1  lf -remote `send $id source ~/.config/lf/profiles/${$argv[0]}`
  • Bash:
1  lf -remote "send $id source ~/.config/lf/profiles/$1"

Advantages:

  • Lumesh: Supports configuration file switching, string interpolation syntax is concise
  • Bash: String interpolation syntax is straightforward

19. zox/z Command (zoxide Integration)
#

Key Binding: ; (push :zox), gz (push :zox)

Code Comparison:

  • Lumesh: Uses conditional expressions and function calls
1if len($argv) {
2    let select=zoxide query --exclude (pwd()) $argv ?: lf -remote "send $id echo Cancelled."
3    lf -remote `send $id cd $select`
4}
  • Bash: Uses conditional checks and command substitution
1if [ -n "$@" ]; then
2    select="$(zoxide query --exclude $PWD $@)" \
3    && lf -remote "send $id cd $select" \
4    || lf -remote "send $id echo Cancelled."
5fi

Advantages:

  • Lumesh: len() function is clear in semantics, pwd() function call is intuitive
  • Bash: Logical operators allow for standard chaining, error handling is explicit

20. cd-usermedia Command
#

Key Binding: gi

Code Comparison:

  • Lumesh: Uses environment variables
1lf -remote `send $id cd $XDG_RUNTIME_DIR/media`
2# or
3lf -remote `send $id cd /run/user/${id -u}/media`
  • Bash: Uses command substitution
1lf -remote "send $id cd /run/user/$(id -u)/media"

Advantages:

  • Lumesh: Directly uses environment variables, more compliant with XDG specifications
  • Bash: Dynamically retrieves user ID, better compatibility

21. follow-link Command#

Key Binding: gL

Code Comparison:

  • Lumesh: Uses variable assignment
1lf -remote `send $id select ${readlink $f}`
  • Bash: Uses command substitution
1lf -remote "send ${id} select '$(readlink $f)'"

Advantages:

  • Lumesh: Variable assignment syntax is clear and readable
  • Bash: Inline command substitution is compact, reducing variable usage

22. fzf-edit Command
#

Key Binding: fe

Code Comparison:

  • Lumesh: Simple command invocation
1hx (fzf)
  • Bash: Uses command substitution
1hx $(fzf)

Advantages:

  • Lumesh: Parentheses syntax is more modern
  • Bash: Traditional command substitution syntax is standard

23. fzf-file Command
#

Key Binding: ff<space>, fft (txt), ffg (gz), ffm (md), ffs (sh), ffy (py)

Code Comparison:

  • Lumesh: Uses ternary operator and string concatenation
1let ext = len($argv) ? '-e'+$argv[0] : ''
2let selected = fd --type 'file' $ext '-S-50k' | fzf --preview "~/.config/lf/previewer {} 30 18"
  • Bash: Uses conditional checks and variable assignment
1[ -n ${1:-''} ] && E="-e$1" || E='-S-50k'
2select=$($lf_user_wheel fd --type f $E | fzf --preview "~/.config/lf/previewer {} 30 18")

Advantages:

  • Lumesh: Ternary operator is concise, string concatenation is intuitive
  • Bash: Parameter expansion syntax is flexible, logical operators are standard

24. fzf-folder Command
#

Key Binding: fd

Code Comparison:

  • Lumesh: Uses variable assignment and conditional checks
1select = $lf_user_wheel fd --type d '.' -d 5 | fzf --preview 'ls {}'
2if $select {
3    lf -remote `send $id cd $select`
4}
  • Bash: Uses command substitution and logical operators
1select=$($lf_user_wheel fd --type d . -d 5 | fzf --preview 'ls {}') \
2&& lf -remote "send $id cd $select" \
3|| lf -remote "send $id echo Cancelled."

Advantages:

  • Lumesh: Variable assignment syntax is clear, no explicit error handling needed
  • Bash: Logical operators allow for standard chaining, error handling is explicit

25. filter Series Commands
#

Key Binding: \\ (filter), F<space> (filter), Ft (.txt), Fp (.png), Fj (.jpg), Fa (.mp3), Fv (.mp4), Fw (.docx), Fx (.xlsx), Fg (.gz), Fz (.zip), Fm (.md), Fs (.sh), Fy (.py), Fc (clear)

Code Comparison:

  • Code is consistent across both implementations.

26. delete Command
#

Key Binding: dD

Code Comparison:

  • Lumesh: Uses modern output and confirmation
1println '=====DELETE====='.red().bold() $fx '================'.red()
2if Ui.confirm('Delete these files [y/n]:'){
3    $lf_user_wheel rm -rf $fx.lines()
4}
  • Bash: Uses traditional echo and read
1echo -e "=====\033[31mDELETE\033[0m====="
2echo "$fx"
3echo "================"
4printf "Delete %d files? [y/N]" $(wc -w <<< $fx)
5read ans
6if [ "$ans" = "y" ]; then
7    echo $fx | xargs $lf_user_wheel rm -rf
8fi

Advantages:

  • Lumesh: Built-in color methods and confirmation functions, syntax is more modern
  • Bash: ANSI escape sequences allow for direct control, wc accurately counts files

27. trash Command
#

Key Binding: dd

Code Comparison:

  • Lumesh: Uses built-in functions and string interpolation
1let files = $fx.lines() | List.map(Fs.base_name)
2let ans = read `Trash: $files [y/N]`
3if $ans == 'y' {
4    mkdir -p /tmp/.trash
5    $lf_user_wheel mv -- $fx.lines() /tmp/.trash/
6    print 'Trash complete!'
7}
  • Bash: Uses traditional tools and command substitution
1printf "Temporary Trash %d files? [y/N]" $(wc -w <<< $fx)
2read ans
3if [ "$ans" = "y" ]; then
4    [ -d "/tmp/.trash" ] || mkdir -p /tmp/.trash
5    echo $fx | xargs $lf_user_wheel rm -rf
6    echo "Trash complete!"
7fi

Advantages:

  • Lumesh: Functional handling of file lists, string interpolation displays file names
  • Bash: Accurate file count statistics, conditional directory creation is concise

28. link Command#

Key Binding: pL

Code Comparison:

  • Lumesh: Uses filesystem functions and loops
 1let load= Fs.read ~/.local/share/lf/files | .lines()
 2let files=$load.drop(1)
 3let base_names = $files.map(Fs.base_name)
 4for filex in $base_names{
 5    if (Fs.exists Fs.join('.',$filex)) {
 6        eprint $filex 'Already exists!'
 7        exit 1
 8    }
 9}
10match $mode {
11    copy => $lf_user_wheel ln -s -- $files '.'
12    move => $lf_user_wheel ln -- $files '.'
13}
  • Bash: Uses sed and basename
 1load=$(cat ~/.local/share/lf/files)
 2mode=$(echo "$load" | sed -n '1p')
 3list=$(echo "$load" | sed '1d')
 4if [ "$mode" = 'copy' ]; then
 5    $lf_user_wheel ln -s $list .
 6elif [ "$mode" = 'move' ]; then
 7    $lf_user_wheel ln $list .
 8fi
 9fn=$(basename -a -- $list)
10for file in "$fn";do
11    lf -remote "send $id :select $file; tag @"
12done

Advantages:

  • Lumesh: Built-in filesystem functions are rich, existence checks are type-safe
  • Bash: Sed text processing is efficient, basename handles batch processing standard

29. paste-rsync Command
#

Key Binding: pr

Code Comparison:

  • Lumesh: Uses pattern matching
 1let load= Fs.read ~/.local/share/lf/files | .lines()
 2let mode=$load.at(0)
 3let files=$load.drop(1)
 4match $mode{
 5    copy => {
 6        $lf_user_wheel rsync -ar --ignore-existing --info=progress2 -- $files '.'
 7    }
 8    move => {
 9        $lf_user_wheel rsync -ar --remove-source-files --ignore-existing --info=progress2 -- $files '.'
10    }
11}
  • Bash: Uses case statement and pipeline processing
1set -- $(cat ~/.local/share/lf/files)
2mode="${1:-}"
3shift
4case "$mode" in
5copy) $lf_user_wheel rsync -av --ignore-existing --progress -- "$@" . | stdbuf -i0 -o0 -e0 tr '\r' '\n' | while IFS= read -r line; do
6    lf -remote "send $id echo $line"
7done ;;
8move) $lf_user_wheel mv -n -- "$@" . ;;
9esac

Advantages:

  • Lumesh: Modern syntax for pattern matching, array operations are intuitive
  • Bash: Positional parameter handling is flexible, real-time progress display is comprehensive

30. paste-to/paste-from Command
#

Key Binding: pt (paste-to), pf (paste-from)

Code Comparison:

  • Lumesh: Uses error handling operators and conditional checks
1let dest = $argv[0] ?: {print 'Cancelled';exit 0}
2$lf_user_wheel cp -r --backup=numbered -i -- $fx $dest
3if Fs.is_dir($dest){
4    let base_names = $fx.lines() | .map(Fs.base_name) | .join("\n")
5    lf -remote `send $id :unselect; cd $dest; select $base_names`
6}
  • Bash: Uses parameter expansion and conditional checks
1if [ -n "${1:-}" ]; then
2    $lf_user_wheel cp -r --backup=numbered -i -- $fx $1
3    [ -d "$1" ] \
4    && lf -remote "send $id :unselect; cd $1; select $(basename $fx)" \
5    || lf -remote "send $id :unselect; select $1; "
6else
7    echo "Cancelled."
8fi

Advantages:

  • Lumesh: Error handling operators are concise, filesystem functions are type-safe
  • Bash: Parameter expansion is standard, logical operators allow for clear chaining

Complete Functionality Comparison Summary
#

Advanced Feature Comparison
#

Feature CategoryLumesh FeaturesBash Features
Error Handling?:, ?., ?! operators&&, `
Data ProcessingChained calls, functional programmingPipelines, text processing tools
File OperationsBuilt-in Fs module, type safetyStandard Unix tools
User InteractionUi.confirm, Ui.pickread, fzf
String ProcessingBuilt-in methods, interpolationcut, sed, awk

Code Maintainability
#

Lumesh Advantages:

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

Bash Advantages:

  • Extensive community support
  • Rich documentation resources

Notes
#

Through the complete comparison of all commands, it is evident that Lumesh has significant advantages in syntax modernization, type safety, and code readability, while Bash is more mature in compatibility. Both implementations can accomplish the same file management tasks, and the choice primarily depends on the user's preference for modern syntax versus reliance on traditional Unix tools.

Read more:

Related