Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/gko/listbox

đŸ’Ŧ listbox element for bash
https://github.com/gko/listbox

bash bashrc list listbox listbox-element zsh zshrc

Last synced: about 2 months ago
JSON representation

đŸ’Ŧ listbox element for bash

Lists

README

        

# Listbox

đŸ’Ŧ listbox element for bash

![demo](https://github.com/gko/listbox/raw/master/demo.gif)

Simple bash listbox to choose from options

## Installation

### Manually

```bash
git clone https://github.com/gko/listbox
```

then in .bashrc or .zshrc:

```bash
source ./listbox/listbox.sh
```

### With [Fig](https://fig.io)

Fig adds apps, shortcuts, and autocomplete to your existing terminal.

Install `listbox` in just one click.

### With [antigen](https://github.com/zsh-users/antigen)

In your .zshrc

```sh
antigen bundle gko/listbox
```

### With [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)

```sh
git clone https://github.com/gko/listbox.git ~/.oh-my-zsh/custom/plugins/listbox

```

then in your .zshrc

```bash
plugins=(
...
listbox
...
)
```

## Usage

```bash
Usage: listbox [options]
Example:
listbox -t title -o "option 1|option 2|option 3" -r resultVariable -a '>'
Options:
-h, --help help
-t, --title list title
-o, --options "option 1|option 2" listbox options
-r, --result result variable
-a, --arrow selected option symbol
```

### General usage

```bash
source ./listbox.sh
listbox -t Title -o "option 1|option 2|option 3" -r result
echo "user chose: $result"
```

output:

```bash
Title
-----
option 1
> option 2
option 3

user chose: option 2
```

### Specify arrow symbol

```bash
listbox -t Title -o "option 1|option 2|option 3" -a '→'
```

output:

```bash
Title
---
→ option 1
option 2
option 3

option 1
```

### Pipe directly to variable

```bash
result=$(listbox -t Title -o "option 1|option 2|option 3" | tee /dev/tty | tail -n 1)
echo "user chose: $result"
```

output:

```bash
Title
---
option 1
> option 2
option 3

user chose: option 2
```

## Like it?

:star: this repo

## License

[MIT](http://opensource.org/licenses/MIT)

Copyright (c) 2012-2016 Konstantin Gorodinskiy