Version 0.5.0: pick, Zeilen auf dem Terminal wählen

This commit is contained in:
wkh
2026-10-11 22:25:45 +02:00
parent e7a7577900
commit d2c4343136
9 changed files with 468 additions and 4 deletions
+13
View File
@@ -265,3 +265,16 @@ bom ; cat bom
## update.inv: change the stock of one item, with record locking (INV names the table)
cp inventory inv ; printf '7\n9\n\n' | INV=inv update.inv | tail -n +2
grep '^7' inv
## ===== Choosing rows on the terminal =====
## pick shows a table, lets you scroll, filter (/) and mark rows (Space, -m), and writes the
## chosen rows as a table, so it can sit in a pipe. It needs a terminal; -k feeds the keys instead.
## Try it: pick -m < inventory | total Amount Value
## mark the 2nd and 5th row (down, space, down, down, space) and finish with enter
pick -m -k 'down space down down space enter' < inventory
## the same chosen rows go on into total
pick -m -k 'down space down down space enter' < inventory | total Amount Value
## filter with / (type, enter), then choose the row that is left
pick -k '/clamps enter enter' < inventory
## Esc cancels: nothing on stdout, exit status 1
pick -k esc < inventory ; echo "status $?"