💾 Archived View for heavysquare.com › unix › 9970-poor-mans-menu-concept.txt captured on 2021-12-03 at 14:04:38.
-=-=-=-=-=-=-
This quick sketch was done to test a few techniques. Vision was to have 1) vi as a sort of form-editor to select/assemble parameters for something 2) expect to get through ssh boundaries and be able to init remote apps 3) navigate the prefix menu with keystrokes (quick) Prefix menu works like giving a list of files, all files should have a unique starting character, keypress is read, then . was pressed, it results a cd .. (in case you're already at the root, the menu session ends) entered character is the first character of a - file, it's executed, like ./file - directory, session continues/repeats in that directory vv details vv % pax -w stty-icanon-menu-system | gzip | openssl base64 H4sIAGuaZFwAA+1ZW2/bNhTeM3/Fmaq1MTZdYznAEuelaLtiwDY0wQY0yWaKoi0h MqWQlC/N8t93SNtpl7T2injG1uh7EBnyXD7q6CNlRWk99wpGRSW8MReNp+ZK8/FX 20SIOEgSsG1v0YZxd9EuANF+dz+K8JqY8aiXJPuQbJXFJ9AoTSVSHEnalPrTdmg2 HK6Js1rIqt02z38J6uP1D0zfV/lWcmyqf68X36l/HEbdCMKtZN+AR15/loG7lxVS 0DEHN+zYwhNZVbrv7tXTrEOmeVFy0LLhJKsIAA4eQqnAi14eAmd5Bb5PcNw8SbB8 lMCzE0+fAsMwWQap6kfAqkZobOPjIOOTQDRl2TE21nPpaPwwmHV39lzWcfCvYghn 4LjMgT44vgMXxgtHBshlYAddwxgn0FjnXGADkEpOL02s8p7/h2Z4B3ABtlcJXQhc J8CwMEuqC3aJ/O1i4U9QPANPgBP87rLguj68OrxxOit63hAzGIc74f3Ajr7n4WUf NzSVuLVU3I6Zu44WVC8oZZXgZLv1X6f/beX4nP0/SiKz/x8kUdTu/zvAuvoHRoVb yPEP6x/H3Qj3/Z7d/7v77fm/C2ysf5CmD82xsf7RvfpjJ27P/x3AHrRpuuVTpcX/ BZv1T+lDc3ye/uOF/sNuq/8dwOqf0lb/jxRr9Z9RzbeQY/P7X/Je//H+4v0vTlr9 7wCmxK34Hy/W6l8xybnwNFdrhLEZm/TfTW5//8cH4eL8P0ja9/9d4DTsD8aXWPF6 QBjVcOyehnB09OLnl2RU1TmX3wdBzulkrq4aKrnPqjHJta5xeDqd+qNGc5FyOfIr OQoYZTkPeN2kQRz1gnqEV1/PNDHhyKQAE/xbR4hK8jGt4ej5m2PIstHo11f127cO ISevT1/0B5gvM1/c0HpA5Ni0hJze47mkuXhIYVIQVZeFJpKr4h0HLyHDijUKsmoq VkZ+4M9qzrR9pME16ZZWTb0guTT0rt6cgLJWHkMCX+wWuVb/H9ysh+TYpP9elKz0 j7oPF/oP2+//u8CTr4NGySAtRMBttcEbEqIlqvPafoJWXIOspgrO7Gd60724nWBV uZrAbjMWq7mVKbj2upwE1zocgatqOhV/VI3eUyWd8O/Mvx865AZ+e/3T8x8IeQLD SjIOFH45iYg1BpUbKV7jQP/ZbDaDZ8BnnOHwDSEr6pLDtZlzb+AQCYoMnIUROquq LM6lY4KzSmD8cSFGgBtRpTlwMTGpApXzsoS98wZ/lKbnZz9CoZBEyvkQV1hyKr2y ENyE1pDO4Z3KO39L/g3cut7lUM7FDM7QPeNIkMrRBMILS6gQmkvK9Be7ybRo0aJF ixYtWrT4z+AvfSxamQAoAAA= % cd stty-icanon-menu-system % find . -type f | xargs pr -F -n Feb 13 22:16 2019 ./menu.sh Page 1 1 cd $(dirname $0)/menu 2 root=$(pwd) 3 while true 4 do 5 pwd; ls -1F; echo .. 6 7 stty -icanon -echo && c=$(dd bs=1 count=1 2>/dev/null) && stty icanon echo 8 echo "($c)" 9 if [ "$c" = "." ] && [ "`pwd`" = "$root" ] 10 then 11 break 12 elif [ "$c" = "." ] 13 then 14 cd .. 15 continue 16 fi 17 18 pick=$(ls -1 | sed -n "/^$c/{p;q;}") 19 if [ -f "$pick" ] 20 then 21 ./$pick 22 elif [ -d "$pick" ] 23 then 24 cd $pick 25 else 26 true that 27 fi 28 done Jan 24 19:22 2019 ./menu/echo/bb Page 1 1 echo bb Jan 24 19:22 2019 ./menu/echo/aa Page 1 1 echo aa Jan 24 19:21 2019 ./menu/date Page 1 1 date Feb 13 22:10 2019 ./menu/screen-test Page 1 1 T0=`mktemp` 2 cat >$T0 <<EOF 3 gopher://heavysquare.com 4 http://www.gutenberg.org/cache/epub/216/pg216.txt 5 EOF 6 7 vi $T0 +"nnoremap <CR> ddggVGpZZ" 8 9 SITE=`head -1 $T0` 10 rm $T0 11 12 T=`mktemp` 13 cat >$T <<EOF 14 screen vi 15 split 16 resize -5 17 focus down 18 screen ./.xpect-test $SITE 19 focus up 20 EOF 21 22 screen -qRS stest -c $T Feb 13 22:02 2019 ./menu/.xpect-test Page 1 1 #!/usr/bin/expect -f 2 3 trap { 4 set rows [stty rows] 5 set cols [stty columns] 6 stty rows $rows columns $cols < $spawn_out(slave,name) 7 } WINCH 8 9 # force a PS1 10 spawn sh -c {PS1='xxx ' exec sh} 11 12 expect -re {xxx $} ; send "exec ssh soli\r" 13 14 # conforming remote env PS1/shell (\u001b\[K is a beefy clear-line sent by zsh) 15 expect -re {% \u001b\[K$} ; send "exec lynx [lindex $argv 0]\r" 16 17 interact %