[](https://joknarf.github.io/joknarf-tools)
[](https://github.com/joknarf/selector/actions/workflows/release.yml)
[](https://github.com/joknarf/selector/releases/latest)
[]()
[](https://shields.io/)
# selector
Shell interactive menu (bash/zsh/ksh compatible)
Pure shell fzf-like

## features
* dynamic interactive menu with items filtering / selection
* optional description of items
* customizable key interaction
* browse directories and display file/folder/links icons (using left/right arrows to navigate in directories)
* view/edit files (right arrow on file/F4 to edit)
* browse archive files/view files in archives (recent `lesspipe` needed)
* customizable colors/icons
## demo

## install
Use a shell plugin manager like the famous [thefly](https://github.com/joknarf/thefly) or use your favorite OS package manager with [release](https://github.com/joknarf/selector/releases/latest) packages
```
fly add joknarf/selector
or
brew install joknarf/tools/selector
dnf install https://github.com/joknarf/selector/releases/latest/download/selector.rpm
...
```
see [joknarf tools](https://joknarf.github.io/joknarf-tools) for package repositories
## usage
```
usage: selector [-p ] [-P ] [-k ] [-m ] [-o ] -i
selector [-p ] [-P ] [-k ] [-m ] [-o ] -f
args :
-p, --prompt menu prompt
-i, --items menu items \n separated [description \t separated]
-f, --file file with items or - for stdin
-F, --filter initial value of filter text (no initial filtering)
-P, --powerline , powerline symbol usage
-a, --autofilter , filter at keystrokes (default y)
-k, --keyfunc Custom additional key function (using selector as function)
-m, --max max number of items displayed
-o, --option | render icons/browse
-q, --quiet silent selected item output
```
selector can be used as command line or sourced to be used as function (bash/zsh/ksh compatible)
When sourced, the selected item is available as `$selected`.
## keys
|key | action |
|--------------------------------|-------------------------------------------------------|
|▼ | select next item |
|▲ | select prev item |
|End/▶ | select last item |
|Home/◀ | select first item |
|Shift▼/PgUp/CtlF| next page |
|Shift▲/PgDn/CtlB| previous page|
|Del/F8 | delete item in menu |
|Esc | exit |
|CtrlA | use all screen to display menu |
|Tab | apply/new filter |
|Enter | validate item selected |
|Alti | switch ignore case on/off |
|CtrlL | refresh / resize menu according to term size |
* filter pattern can be applied entering text
* selection can be done entering item number
when `dirnames` or `filenames` option, additional keys can be used:
|key | action |
|--------------------------------|-------------------------------------------------------|
|▶ | browse selected directory/view selected file |
|◀ | browse parent directory |
|Shift▶ | browse selected directory with subdirectories depth +1 |
|Shift◀ | back to only show subdirectories depth 1 |
|F4 | edit file using EDITOR |
|F1 | hide dotfiles |
# customize
selector menu can be customized setting following variables:
```
SELECTOR_FOLDER_ICON=🖿 # folder icon
SELECTOR_FILE_ICON=📄 # file icon
SELECTOR_CASEI=0 # ignore case filter 0/1
SELECTOR_POWERLINE=y # avoid using glyphs with 'n'
SELECTOR_COL_PROMPT="30;90;180" # blue
SELECTOR_COL_TEXT="255;255;255" # white
SELECTOR_COL_TOTAL="32;64;64" # darkggrey
SELECTOR_COL_NUM="36;114;67" # green
SELECTOR_COL_ARROW="41;98;114" # cyan
SELECTOR_COL_ITEM="118;141;255" # light blue
SELECTOR_COL_SELECTED="42;221;244" # light cyan
```
demo usage at:
* [shell-ng](https://github.com/joknarf/shell-ng) : bash/zsh/ksh shell next gen plugin, compilation including following plugins:
* [seedee](https://github.com/joknarf/seedee) : navigate in directories from command line with arrow keys with dir history (bash/zsh/ksh)
* [redo](https://github.com/joknarf/redo) : replacement for CtrlR and Esc/ to search in command history (bash/zsh)
* [complete-ng](https://github.com/joknarf/complete-ng) : bash/zsh command line completion replacement for multiple choices output with interactive menu