A shell command that will display a selection list. It is similar to
selecta, but uses curses library to do display, and when compared to
fzf, the main difference is approximate matching instead of fuzzy matching.
It is written in Z shell and has its capabilities:
- Patterns, allowing multi-term searching
- Curses module
- Approximate matching Ctrl-F
zsh-select can be copied to any
Zsh will serve as say
zsh-select will be a regular program available in the system.
Pressing o will make elements uniqe. To search again after pressing enter, press /. Approximate matching mode is activated by Ctrl-F.
Install Zsh Select
zsh-select will be available in interactive
Zsh sessions only when using this method. Nevertheless, integration with
Vim and other methods will work when
Zsh is your main shell.
Simply copy file
zsh-select to any
bin directory such as
Add the following to
.zshrc. The plugin will be loaded next time you start
Zsh. To update issue
zi update z-shell/zsh-select from command line.
zi load z-shell/zsh-select
Add the following to
.zshrc and issue a
zgen reset (this assumes that there is a proper
zgen save construct in
zgen load z-shell/zsh-select
Adding the following snippet to
.vimrc will provide a
\f keyboard shortcut that will run
zsh-select as file-selector.
Multi-term searching and approximate matching Ctrl-F will be available. The snippet is based on code from the
selecta GitHub page (MIT license):
" Run a given vim command on the results of fuzzy selecting from a given shell
" command. See usage below.
function! ZshSelectCommand(choice_command, zshselect_args, vim_command)
let selection = system(a:choice_command . " | zsh-select " . a:zshselect_args)
" Swallow the ^C so that the redraw below happens; otherwise there will be
" leftovers from zshselect on the screen
exec a:vim_command . " " . selection
" Find all files in all non-dot directories starting in the working directory.
" Fuzzy select one of those. Open the selected file with :e.
nnoremap <leader>f :call ZshSelectCommand("find * -type f 2>/dev/null", "", ":e")<cr>
There are a few environment variables that can be set to alter
The values assigned below are the defaults:
export ZSHSELECT_BOLD="1" # The interface will be drawn in bold font. Use "0" for no bold
export ZSHSELECT_COLOR_PAIR="white/black" # Draw in white foreground, black background. Try e.g.: "white/green"
export ZSHSELECT_BORDER="0" # No border around interface, Use "1" for the border
export ZSHSELECT_ACTIVE_TEXT="reverse" # Mark current element with reversed text. Use "underline" for marking with underline
export ZSHSELECT_START_IN_SEARCH_MODE="1" # Starts Zsh Select with searching active. "0" will not invoke searching at the start.