Version 0.5.0: pick, Zeilen auf dem Terminal wählen
This commit is contained in:
@@ -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 $?"
|
||||
|
||||
+26
-2
@@ -845,9 +845,9 @@ Item Amount Cost Value Description
|
||||
## tabletom4 / tabletosed / tabletostruct were shown above
|
||||
## ===== Help and the terminal =====
|
||||
$ rdb --version
|
||||
rdb 0.4.0
|
||||
rdb 0.5.0
|
||||
$ howmany
|
||||
135
|
||||
136
|
||||
$ whatis row
|
||||
row - make a new table where rows match logical condition
|
||||
row row 'column condition column-or-value ..' < table
|
||||
@@ -1107,3 +1107,27 @@ Item Number: (or hit Return key to exit.) Item=7 Amount=5 Cost=175.00 Value=8
|
||||
Amount Amount: Item Number: (or hit Return key to exit.)
|
||||
$ grep '^7' inv
|
||||
7 9 175.00 1575 scales
|
||||
## ===== 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
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- -----------
|
||||
2 100 0.50 50.00 test tubes
|
||||
5 99 2.45 242.55 cleaning cloth
|
||||
## the same chosen rows go on into total
|
||||
$ pick -m -k 'down space down down space enter' < inventory | total Amount Value
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- -----------
|
||||
199 292.55
|
||||
## filter with / (type, enter), then choose the row that is left
|
||||
$ pick -k '/clamps enter enter' < inventory
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- -----------
|
||||
3 6 8.00 48.00 clamps
|
||||
## Esc cancels: nothing on stdout, exit status 1
|
||||
$ pick -k esc < inventory ; echo "status $?"
|
||||
pick: nothing chosen
|
||||
status 1
|
||||
|
||||
Reference in New Issue
Block a user