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-filesseries - 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 searchfilterseries - 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:
1set shell lumesh # Required
2set shellopts '-s' # Optional
3set ifs "\n" # Optional
4set filesep "\n" # Optional- To enable bash in lf:
1set shell bash # Required
2set shellopts '-eu' # Optional
3set ifs "\n" # Optional
4set filesep "\n" # OptionalMain Command Comparison A#
1. all-cmd Command#
Key Binding: <c-e>
Syntax Comparison:
- lumesh: Uses a chained pipeline method and built-in functions
1let 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
1cmd=$( 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.pickprovides a unified interaction experience. - bash: Uses standard Unix tools, good compatibility,
awkoffers more flexible text processing.
2. history-cmd Command#
Key Binding: <backspace>, <backspace2>
Syntax Comparison:
- lumesh:
1let cmd = lf -remote `query $id history` | .lines() | .sort() | Ui.pick "history command:" | .split("\t\t") | .last()- bash:
1cmd=$( 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$NFefficiently handles the last column.
3. toggle-preview Command#
Key Binding: zp
Syntax Comparison:
- lumesh: Uses pattern matching
1match $lf_preview {
2 'true' => lf -remote `send $id :set nopreview; set ratios 1:5`
3 _ => lf -remote `send $id :set preview; set ratios 1:2:3`
4}- bash: Uses conditional statements
1if [ "$lf_preview" = "true" ]; then
2 lf -remote "send $id :set nopreview; set ratios 1:5"
3else
4 lf -remote "send $id :set preview; set ratios 1:2:3"
5fiAdvantages:
- lumesh:
matchsyntax is more modern, powerful pattern matching; variables do not require quotes. - bash: Traditional
if-elsestructure 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
1let htag= $lf_hidden ? '-H' : ''
2let r=fd --exact-depth 1 $argv $htag -c never -j 1 | .lines() | .join(' ')- bash: Uses functions and conditional statements
1get_files() {
2 if [ "$lf_hidden" = 'false' ]; then
3 fd --exact-depth 1 $@ -c never -j 1 -0
4 else
5 fd --exact-depth 1 $@ -H -c never -j 1 -0
6 fi | xargs -0 printf ' %q'
7}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
1let file_type = len($argv)>0 ? $argv[0] : 'sh'
2let RG_PREFIX = `$lf_user_wheel rg --type $file_type --column --line-number --no-heading --color=always --smart-case --max-filesize 50K`
3if $res {
4 let a = $res.split(':').take(3).join(':')
5 $lf_user_wheel hx $a
6}- bash: Uses traditional shell syntax
1RG_PREFIX="$lf_user_wheel rg --column --line-number --no-heading --color=always --smart-case --max-filesize 50K"
2[ -n ${1:-''} ] && RG_PREFIX="$RG_PREFIX --type $1"
3[ -n "$res" ] && $lf_user_wheel hx $(echo $res|cut -d: -f1) +$(echo $res|cut -d: -f2)Advantages:
- lumesh: String method chaining is more intuitive, conditional expressions are concise.
- bash: Parameter expansion is flexible,
cutcommand efficiently handles delimiters.
6. yank Series Commands#
Key Binding: yp (path), yn (filename), yb (basename), yu (clear)
Syntax Comparison:
- lumesh: Uses functional programming style
1$fx.lines() | .map(Fs.base_name) | .join("\n") | wl-copy
2$fx.lines() | .map(x -> {Fs.base_name(True,$x) | .first()}) | .join("\n") | wl-copy- bash: Uses traditional Unix tools
1basename -a -- "$fx" | head -c-1 | wl-copy
2echo $fx | tr ' ' '\n' | wl-copy
3basename -a -- "$fx" | cut -d. -f1 | head -c-1 | wl-copyAdvantages:
- 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
1let load=Fs.read ~/.local/share/lf/files | .lines()
2let mode=$load.at(0)
3let files = $load.drop(1)
4let base_names = $files.map(Fs.base_name)
5match $mode {
6 copy => { $lf_user_wheel cp -r $argv -- $files '.' }
7 move => { $lf_user_wheel mv -- $files '.' }
8}- bash: Uses traditional text processing
1load=$(cat ~/.local/share/lf/files)
2mode=$(echo "$load" | sed -n '1p')
3list=$(echo "$load" | sed '1d')
4fn=$(basename -a -- $list)
5if [ "$mode" = 'copy' ]; then
6 $lf_user_wheel cp -r $@ -- $list .
7elif [ "$mode" = 'move' ]; then
8 $lf_user_wheel mv -- $list .
9fiAdvantages:
- 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
1let old_files = $fs.lines()
2let new_files = Fs.read $new | .lines()
3for pair in List.zip($old_files,$new_files){
4 if $pair[0] != $pair[1]{
5 $lf_user_wheel mv -- $pair[0] $pair[1]
6 }
7}- bash: Uses traditional text processing
1paste "$old" "$new" | while IFS= read -r names; do
2 src="$(printf '%s' "$names" | cut -f1)"
3 dst="$(printf '%s' "$names" | cut -f2)"
4 if [ "$src" = "$dst" ] || [ -e "$dst" ]; then
5 continue
6 fi
7 $lf_user_wheel mv -- "$src" "$dst"
8doneAdvantages:
- lumesh:
List.zipfunctional operation is elegant, array access is intuitive. - bash:
pastecommand is professional, pipeline processing is memory efficient.
9. mount-dev Command#
Key Binding: mm
Syntax Comparison:
- lumesh: Uses structured data processing
1let sel = lsblk -rno 'name,type,size,mountpoint,label,fstype' | Into.table([name,'type',size,mountpoint,label,fstype])
2| where($type!='disk' && !$mountpoint && $fstype !~: 'member')
3| Ui.pick "which to mount:"
4let src = $sel.type == 'part' ? `/dev/${$sel.name}` : `/dev/mapper/${$sel.name}`- bash: Uses text processing and field extraction
1sel=$(lsblk -rno 'name,type,size,label,mountpoint,fstype' |
2awk -F'[ ]' '$2!="disk" && $5=="" && $6!~/member/ { print $1,$2,$3,$4 }' |
3fzf --prompt='choose to Mount: ' --preview='')
4x=$(echo "$sel" | cut -d' ' -f1)
5typ=$(echo $sel | cut -d' ' -f2)Advantages:
- lumesh: Powerful structured data processing, type-safe field access, intuitive
wherefiltering. - 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