readme
This commit is contained in:
37
README.md
37
README.md
@@ -11,3 +11,40 @@ Selecting a drive from the system
|
||||
```bash
|
||||
lsblk -lno type,name | grep part | awk '{ print "/dev/" $2 }' | select_option
|
||||
```
|
||||
|
||||
If you use the wrapper you can then pipe your output to more commands:
|
||||
```bash
|
||||
lsblk -lno type,name | grep part | awk '{ print "/dev/" $2 }' | ./wrapper.sh | xargs -I% echo Mounting %...
|
||||
|
||||
```
|
||||
|
||||
### What about bash's `select`?
|
||||
|
||||
I didn't know this existed when I wrote this program.
|
||||
But on the plus side they aren't exact copies of eachother.
|
||||
Bash's `select` works like:
|
||||
```bash
|
||||
select x in a b c; do
|
||||
echo "selected: $x"
|
||||
break
|
||||
done
|
||||
```
|
||||
Where it just creates a little text menu:
|
||||
```txt
|
||||
1) one
|
||||
2) two
|
||||
3) three
|
||||
#?
|
||||
```
|
||||
Of which you can input your number.
|
||||
This has some issues:
|
||||
|
||||
1. You can select values that are out of bounds. Meaning that your script to be defensivly programmed.
|
||||
1. You can't use vim keys to move around.
|
||||
1. It is harder to implement into a stream since you have to turn your agruments into an array. (Seems to be designed for scripts, not one-liners.)
|
||||
1. I didn't make the program.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user