Skip to content

joknarf/selector

Repository files navigation

Joknarf Tools Build and Release Packages Packages bash Licence

selector

Shell interactive menu (bash/zsh/ksh compatible)

image

features

  • dynamic interactive menu with items filtering / selection
  • customizable key interaction
  • possible display file/folder icons
  • customizable colors

demo

selector

install

Use a shell plugin manager like the famous thefly or use your favorite OS package manager with release 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 for package repositories

usage

usage: selector [-p <prompt>] -i <items>|-f <itemfile> [-P <y|n>]
args :
  -p, --prompt          menu prompt
  -i, --items           menu items \n separated
  -f, --file            file with items
  -F, --filter          regexp pattern filter items
  -P, --powerline       y or n, powerline symbol usage
  -a, --autofilter      y or n, filter at keystrokes
  -k, --keyfunc         Custom additional key function

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
  • filter pattern can be applied entering text
  • selection can be done entering item number

customize

selector menu can be customized setting following variables:

SELECTOR_FOLDER_ICON=🖿            # folder icon
SELECTOR_FILE_ICON=📄             # file icon
SELECTOR_CASEI=false               # case sensitivity filter
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:

  • seedee : navigate in directories from command line with arrow keys with dir history (bash/zsh/ksh)
  • redo : replacement for CtrlR and Esc/ to search in command history (bash/zsh)
  • complete-ng : bash/zsh command line completion replacement for multiple choices output with interactive menu