Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cdrubin/bash_ui
respond to arrow keys for selections in bash scripts
https://github.com/cdrubin/bash_ui
bash ui
Last synced: 2 months ago
JSON representation
respond to arrow keys for selections in bash scripts
- Host: GitHub
- URL: https://github.com/cdrubin/bash_ui
- Owner: cdrubin
- Created: 2015-11-19T12:44:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-11-09T19:03:46.000Z (3 months ago)
- Last Synced: 2024-11-09T19:35:52.708Z (3 months ago)
- Topics: bash, ui
- Language: Shell
- Homepage:
- Size: 34.2 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bash_ui
Some helpful functions for making interactive bash scripts on Linux terminal respond to cursor keys for data entry.(and now not dependent on tput from ncurses)
[_DOWNLOAD_](https://raw.githubusercontent.com/cdrubin/bash_ui/master/bash_ui.sh)
## _select_, _multi-select_ and _select value_
----------
### Example 1 (_select_):Allow a user to select a path
```sh
source bash_ui.sh
CHOICES=`find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n'`
choose_oneecho $CHOSEN
```
---------
### Example 2 (_select multiple_):Ask user to select from a set of options
```sh
source bash_ui.sh
CHOICES=`find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n'`
choose_multipleecho $CHOSEN
```
---------
### Example 3 (_select_):```sh
source bash_ui.sh
read -r -d '' CHOICES <&1 1>/dev/tty)
echo "Chosen home dir: $result"```
----------
### Example 6 (_select multiple_)```sh
#!/bin/bashresult=$(find /home -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | ./shui multiple 2>&1 1>/dev/tty)
echo "Chosen home directories:"
echo "$result"```
----------
### Example 7 (_select multiple from provided heredoc_)```sh
#!/bin/bashecho "Choose your favourite characters"
read -r -d '' CHOICES <<- EOS
Roger Ellison
Duiwel Dewet
Roger Rabbit
EOSresult=$(echo -e "$CHOICES" | ./shui 2>&1 1>/dev/tty)
```