Compare commits

...

2 Commits

Author SHA1 Message Date
c5abd70e65 assume program is installed 2026-02-03 14:35:52 -07:00
17bd886e3a add recipies 2026-02-03 14:35:26 -07:00
2 changed files with 38 additions and 1 deletions

View File

@@ -47,4 +47,41 @@ This has some issues:
Interestingly, I found the same trick they use to allow for menus to be printed but also pipe the output.
By putting them menu on `stderr` instead of `stdout` you can have a menu that doesn't get yoinked by the pipe's reidrection.
# Recipies
> Note: I have the program wrapper script on my `$PATH` and have the wrapper script renamed to `opts`.
Show all directories, entering the selected one.
```bash
cd $(ls -la | grep dr | awk '{ print $9 }' | opts)
```
---
Show all partitions, mounting the selected one at `/mnt`.
```bash
sudo mount $(lsblk -lno type,name | grep part | awk '{ print "/dev/" $2 }' | opts) /mnt
```
You could even do the filtering after the fact, to give the user more info.
```bash
sudo mount $(lsblk | opts | awk '{ print $1 }') /mnt
```
(But this would allow you to select bad data.)
---
Choose what video codec to change all the videos in the current directory to.
```bash
OPTS="mpeg4\nh265\nh264"
SEL=$(printf $OPTS | opts)
for x in $(ls); do
ffmpeg -i $x -v:c $SEL ${x}-enc.mp4
done
```

View File

@@ -3,7 +3,7 @@
TMP=$(mktemp)
# Put the output to fd 4 and put the TUI to 2, since pipes redirect 1 by default
cat /dev/stdin | ./target/release/select_option $TMP 1>&2
cat /dev/stdin | select_option $TMP 1>&2
cat $TMP
rm $TMP