github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/config/defaults/profile_linux.mx (about) 1 function progress { 2 # Pulls the read progress of a Linux pid via /proc/$pid/fdinfo (only runs on Linux) 3 4 if { ${os}=="linux" } then { 5 #params -> [ 1 ] -> set pid 6 $1 -> set pid 7 8 g <!null> /proc/$pid/fd/* -> regexp <!null> (f,/proc/[0-9]+/fd/([0-9]+)) -> foreach <!null> fd { 9 trypipe <!null> { 10 open /proc/$pid/fdinfo/$fd -> cast yaml -> [ pos ] -> set pos 11 readlink: /proc/$pid/fd/$fd -> set file 12 du -b $file -> [ :0 ] -> set int size 13 if { = size > 0 } then { 14 = ($pos/$size)*100 -> set int percent 15 out "$percent% ($pos/$size) $file" 16 } 17 } 18 } 19 } 20 } 21 22 autocomplete set progress { 23 [{ 24 "DynamicDesc": ({ 25 ps -A -o pid,cmd --no-headers -> set ps 26 map { $ps[:0] } { $ps -> regexp 'f/^[ 0-9]+ (.*)$' } 27 }), 28 "ListView": true 29 }] 30 } 31 32 config set shell stop-status-func { 33 progress $PID 34 } 35 36 if { or { $WSLENV } { $WSL_DISTRO_NAME } } then { 37 trypipe { 38 mount \ 39 -> regexp (m/[A-Z]:\\/) -> [:2] \ 40 -> cast str -> format json \ 41 -> config: set wsl windows-mounts true 42 } 43 }