lf filemanager 配置对比 B
10. extract-to 命令
按键绑定: ah
(当前目录), ax
(/tmp/), aX
(自定义路径)
写法对比:
- lumesh: 使用正则匹配和内置文件函数
if (Regex.match '\.([gb7xs]z|t[gbx]z|zip|zst|bz2|lz4|lzma|tar|rar|br)$' $f) { |
- bash: 使用case语句和字符串处理
case "$f" in |
优势说明:
- lumesh: 正则表达式更灵活,内置路径操作函数类型安全
- bash: case语句性能更好,模式匹配简洁直观
11. compress-to 命令
按键绑定: ac
(/tmp/压缩)
写法对比:
- lumesh: 使用字符串方法和条件表达式
if $dest.ends_with('/'){ |
- bash: 使用test命令和字符串操作
if test "$(echo $1 | grep '/$')" -o -d "$1" ; then |
优势说明:
- lumesh: 字符串方法更直观,条件表达式简洁
- bash: test命令标准化,dirname/basename工具成熟
12. diff系列命令
按键绑定: df
(diff), dt
(delta), dm
(md5对比)
写法对比:
- lumesh: 使用数组索引和三元运算符
let files = $fs.lines() |
- bash: 使用位置参数和条件判断
set -- $fs |
优势说明:
- lumesh: 数组操作直观,链式调用简洁,三元运算符优雅, 条件语句更直观简洁
- bash: 位置参数灵活,cut命令高效,条件判断清晰
13. check-sum 命令
按键绑定: dc
写法对比:
- lumesh: 使用模式匹配
let ext_name = Fs.base_name(True, $fx).last() |
- bash: 使用case语句
case "$fx" in |
优势说明:
- lumesh: 模式匹配功能强大,文件扩展名提取类型安全。也支持正则和通配符模式。
- bash: case语句性能优秀,通配符匹配简单直接
14. cmus-play 命令
按键绑定: Om
写法对比:
- lumesh: 使用条件表达式和错误处理
pgrep -x cmus ?: foot cmus |
- bash: 使用条件判断和逻辑运算符
if [ -z "$(pgrep -x cmus)" ]; then |
优势说明:
- lumesh: 错误处理运算符
?:
简洁,代码更紧凑 - bash: 条件逻辑清晰,逻辑运算符
&&
链式调用标准
15. umount-dev 命令
按键绑定: mu
写法对比:
- lumesh: 使用结构化数据和可选链
let sel = lsblk -rno 'name,type,size,mountpoint,label,fstype' | Into.table([name,'type',size,mountpoint,label,fstype]) \ |
- bash: 使用awk和字符串处理
x=$(mount | awk '$1 ~ /^\/dev/ && $3 !~/^\/(home|boot|var)?$/ {sub(/^\/dev\//, "", $1); print $1,$5,$3}' | fzf --prompt='choose to UMount: ' --preview='' | awk '{print $3}') |
优势说明:
- lumesh: 结构化数据处理强大,
?.
优雅忽略未选择错误,字段访问类型安全 - bash: awk正则处理灵活,管道组合高效,字符串匹配成熟
16. on-cd 命令
按键绑定: 无(自动触发)
写法对比:
- lumesh: 使用系统函数
Sys.print_tty `\033]0;lf $PWD\007` |
- bash: 使用printf重定向
printf "\033]0;lf $PWD\007" > /dev/tty |
优势说明:
- lumesh: 系统函数封装更安全,API更清晰
- bash: 直接操作设备文件,控制更精确
17. drag系列命令
按键绑定: di
(拖入), do
(拖出)
写法对比:
- lumesh: 使用内置文件函数
dest=dragon-drop --target -x -p |
- bash: 使用basename命令
dest=$(dragon-drop --target -x -p) |
优势说明:
- lumesh: 内置文件函数类型安全,变量作用域清晰
- bash: basename命令标准化,命令替换直接
完整对比总结
语法特性对比
特性 | Lumesh | Bash |
---|---|---|
条件表达式 | condition ? true_val : false_val |
[ condition ] && true_cmd || false_cmd |
模式匹配 | match expr { pattern => action } |
case expr in pattern) action ;; |
数组操作 | .lines() , .map() , .filter() |
awk , cut , sed |
错误处理 | cmd ?: default |
cmd || default |
字符串方法 | .split() , .join() , .ends_with() |
cut , grep , test |
文件操作 | Fs.base_name() , Fs.join() |
basename , dirname |
继续阅读: