Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a few new features #170

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
13247c7
Update manpage
leo-arch Apr 17, 2022
ccc6ff9
Add multi-select and list padding
leo-arch Apr 17, 2022
4a000a5
Rewrote selections code
leo-arch Apr 17, 2022
db015dc
Add comments to new functions
leo-arch Apr 17, 2022
0a8f6ca
Fix wrong var name
leo-arch Apr 17, 2022
5d51294
Update manpage
leo-arch Apr 17, 2022
0eddf61
Add pointer, marker, and cycle options
leo-arch Apr 17, 2022
407ecfe
Fix double free
leo-arch Apr 17, 2022
3f14985
Update README.md
leo-arch Apr 17, 2022
bb4cdfd
Update README.md
leo-arch Apr 17, 2022
f23fb9a
Add color usage description
leo-arch Apr 18, 2022
5efa5b5
Add basic color support
leo-arch Apr 18, 2022
797b6d9
Update README.md
leo-arch Apr 18, 2022
89cf431
Add dash usage description
leo-arch Apr 18, 2022
7bb8336
Merge branch 'master' of ssh://github.com/leo-arch/fzy
leo-arch Apr 18, 2022
f32a015
Add config.h header file
leo-arch Apr 18, 2022
115abca
Fix compilation
leo-arch Apr 18, 2022
ef11838
Run colored by default
leo-arch Apr 18, 2022
eab6fb9
Update manpage
leo-arch Apr 18, 2022
d1f116f
Handle ANSI colors for matches
leo-arch Apr 20, 2022
76dc156
Add prompt at bottom option (reverse)
leo-arch May 5, 2022
959ac57
Update manpage
leo-arch May 5, 2022
1f5c1c7
Fix crash while decoloring output
leo-arch Jun 5, 2022
ce60fd9
Update manpage
leo-arch Jul 9, 2022
00239ab
Update README.md
leo-arch Jul 9, 2022
81a3197
Allow lists of only one entry
leo-arch Feb 14, 2023
3c10f41
Add uninstall target to Makefile
leo-arch Feb 14, 2023
b886626
Bump version to 1.1
leo-arch Jun 6, 2023
e8b1323
Add missing config.h
leo-arch Jun 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ fzy
fzytest
*.o
*.d
config.h
test/acceptance/vendor/bundle
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=1.0
VERSION=1.1

CPPFLAGS=-DVERSION=\"${VERSION}\" -D_GNU_SOURCE
CFLAGS+=-MD -Wall -Wextra -g -std=c99 -O3 -pedantic -Ideps -Werror=vla
Expand Down Expand Up @@ -31,11 +31,11 @@ check: test/fzytest
fzy: $(OBJECTS)
$(CC) $(CFLAGS) $(CCFLAGS) -o $@ $(OBJECTS) $(LIBS)

%.o: %.c config.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
#%.o: %.c config.h
# $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

config.h: src/config.def.h
cp src/config.def.h config.h
#config.h: src/config.def.h
# cp src/config.def.h config.h

install: fzy
mkdir -p $(DESTDIR)$(BINDIR)
Expand All @@ -45,15 +45,20 @@ install: fzy
cp fzy.1 $(DESTDIR)$(MANDIR)/man1/
chmod 644 ${DESTDIR}${MANDIR}/man1/fzy.1

uninstall:
rm -- $(DESTDIR)$(BINDIR)/fzy
rm -- $(DESTDIR)$(MANDIR)/fzy.1

fmt:
clang-format -i src/*.c src/*.h

clean:
rm -f fzy test/fzytest src/*.o src/*.d deps/*/*.o

veryclean: clean
rm -f config.h
#veryclean: clean
# rm -f config.h

.PHONY: test check all clean veryclean install fmt acceptance
#.PHONY: test check all clean veryclean install fmt acceptance
.PHONY: test check all clean install fmt acceptance

-include $(OBJECTS:.o=.d)
61 changes: 16 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@

**fzy** is a fast, simple fuzzy text selector for the terminal with an advanced scoring algorithm.

[Try it out online!](http://jhawthorn.github.io/fzy-demo)
**Disclaimer**: This fork (originaly intended to make fzy work with [the clifm file manager](https://github.com/leo-arch/clifm)) adds a few new features to the origianl fzy, including basic color support and multi-selection. Consult the manpage for more information.

![](http://i.hawth.ca/u/fzy_animated_demo.svg)

<blockquote>
It's been kind of life-changing.
-<a href="https://github.com/graygilmore/">@graygilmore</a>
</blockquote>

<blockquote>
fzy works great btw
-<a href="https://twitter.com/alexblackie/status/719297828892188672">@alexblackie</a>
</blockquote>

[![Build Status](https://github.com/jhawthorn/fzy/workflows/CI/badge.svg)](https://github.com/jhawthorn/fzy/actions)

## Why use this over fzf, pick, selecta, ctrlp, ...?

fzy is faster and shows better results than other fuzzy finders.
Expand All @@ -34,32 +22,13 @@ Rather than clearing the screen, fzy displays its interface directly below the c

## Installation

**macOS**

Using Homebrew

brew install fzy

Using MacPorts

sudo port install fzy

**[Arch Linux](https://www.archlinux.org/packages/?sort=&q=fzy&maintainer=&flagged=)/MSYS2**: `pacman -S fzy`

**[FreeBSD](https://www.freebsd.org/cgi/ports.cgi?query=fzy&stype=all)**: `pkg install fzy`

**[Gentoo Linux](https://packages.gentoo.org/packages/app-shells/fzy)**: `emerge -av app-shells/fzy`

**[Ubuntu](https://packages.ubuntu.com/search?keywords=fzy&searchon=names&suite=bionic&section=all)/[Debian](https://packages.debian.org/search?keywords=fzy&searchon=names&suite=all&section=all)**: `apt-get install fzy`

**[pkgsrc](http://pkgsrc.se/misc/fzy) (NetBSD and others)**: `pkgin install fzy`

**[openSUSE](https://software.opensuse.org/package/fzy)**: `zypper in fzy`

### From source

make
sudo make install
```sh
mkdir build && cd build
git clone https://github.com/leo-arch/fzy
cd fzy
make
sudo make install
```

The `PREFIX` environment variable can be used to specify the install location,
the default is `/usr/local`.
Expand Down Expand Up @@ -98,6 +67,14 @@ nnoremap <leader>v :call FzyCommand("ag . --silent -l -g ''", ":vs")<cr>
nnoremap <leader>s :call FzyCommand("ag . --silent -l -g ''", ":sp")<cr>
```

### Use with [clifm](https://github.com/leo-arch/clifm)

Just run clifm as follows:

```sh
clifm --fzytab
```

## Sorting

fzy attempts to present the best matches first. The following considerations are weighted when sorting:
Expand All @@ -109,9 +86,3 @@ It prefers matching the beginning of words: `amp` is likely to match <tt><b>a</b
It prefers shorter matches: `abce` matches <tt><b>abc</b>d<b>e</b>f</tt> over <tt><b>abc</b> d<b>e</b></tt>.

It prefers shorter candidates: `test` matches <tt><b>test</b>s</tt> over <tt><b>test</b>ing</b></tt>.

## See Also

* [fzy.js](https://github.com/jhawthorn/fzy.js) Javascript port


105 changes: 91 additions & 14 deletions fzy.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH FZY 1 "2018-09-23" "fzy 1.0"
.TH FZY 1 "Jul 9, 2022" "fzy 1.0"
.SH NAME
fzy \- A fuzzy text selector menu for the terminal.
.SH SYNOPSIS
Expand All @@ -25,6 +25,14 @@ How many lines of items to display. If unspecified, defaults to 10 lines.
Input prompt (default: '> ')
.
.TP
.BR \-P ", " \-\-pad =\fINUM\fR
Left pad the list of matches NUM places (default: 0)
.
.TP
.BR \-m ", " \-\-multi
Enable multi-selection
.
.TP
.BR \-s ", " \-\-show-scores
Show the scores for each item.
.
Expand Down Expand Up @@ -52,52 +60,121 @@ Usage help.
.BR \-v ", " \-\-version
Usage help.
.
.TP
.BR \-\-pointer =\fICHAR\fR
Pointer to highlightled match (default '>')
.
.TP
.BR \-\-marker =\fICHAR\fR
Multi-select marker (default '*')
.
.TP
.BR \-\-cyclic
Enable cyclic scrolling
.
.TP
.BR \-\-tab-accetps
TAB accepts: print selection and exit
.
.TP
.BR \-\-right-accepts
Right arrow key accepts: print selection and exit
.
.TP
.BR \-\-left-aborts
Left arrow key aborts: cancel selection and exit
.
.TP
.BR \-\-reverse
List from top, prompt at bottom
.
.TP
.BR \-\-no\-color
Run colorless
.
.SH KEYS
.
.TP
.BR "ENTER"
Print the selected item to stdout and exit
Print the selected items to stdout and exit. If \fI\-\-right\-accepts\fR is set, the Right arrow key performs the same function. Equally, if \fI\-\-tab\-accepts\fR is set, the TAB key performs the same function.
.TP
.BR "ESC"
Exit without printing any result. If \fI\-\-left\-aborts\fR is set, the Left arrow key performs the same function.
.TP
.BR "Ctrl+c, Ctrl+g, Esc"
Exit with status 1, without making a selection.
.TP
.BR "Up Arrow, Ctrl+p, Ctrl+k"
Select the previous item
Select the previous item.
.TP
.BR "Down Arrow, Ctrl+n, Ctrl+j"
Select the next item
Select the next item.
.TP
Tab
Replace the current search string with the selected item
.BR "TAB"
Replace the current search string with the selected item. If the multi-selection mode (\fI-m, --multi\fR) is enabled, TAB is used to (un)mark the selected entry instead.
.TP
.BR "Backspace, Ctrl+h"
Delete the character before the cursor
Delete the character before the cursor.
.TP
.BR Ctrl+w
Delete the word before the cursor
Delete the word before the cursor.
.TP
.BR Ctrl+u
Delete the entire line
Delete the entire line.
.
.SH COLORS
Interface colors are read from the environment variable \fBFZY_COLORS\fR using a simple pattern: the \fIorder\fR of the color code specifies which \fIinterface element\fR the color must be applied to, while the \fIcontent\fR of this code defines the \fIcolor\fR of this element.
.sp
\fBA\fR. The order is this:
1) Prompt
2) Pointer
3) Marker
4) Current entry foreground
5) Current entry background
.sp
\fBB\fR. Possible content (available colors):
0 = black
1 = red
2 = green
3 = yellow
4 = blue
5 = magenta
6 = cyan
7 = white
.sp
Use a \fBb\fR before the color to make it bold/bright. A dash (\-) means that the color for the interface element in that position must be skipped.
.sp
For example, \fBFZF_COLORS="\-b1b2\-4"\fR is to be read as follows:
.sp
\fB\-\fR: no prompt color
\fBb1\fR: bold red pointer color
\fBb2\fR: bold green marker color
\fB\-\fR: no color for the current entry foreground
\fB4\fR: blue current entry background
.sp
Default colors are: \fBb6b1b2b40\fR
.
.SH USAGE EXAMPLES
.
.TP
.BR "ls | fzy"
Present a menu of items in the current directory
.TP
.BR "ls | fzy -l 25"
.BR "ls | fzy \-l 25"
Same as above, but show 25 lines of items
.TP
.BR "vi $(find -type f | fzy)"
.BR "vi $(find \-type f | fzy)"
List files under the current directory and open the one selected in vi.
.TP
.BR "cd $(find -type d | fzy)"
.BR "cd $(find \-type d | fzy)"
Present all directories under current path, and change to the one selected.
.TP
.BR "ps aux | fzy | awk '{ print $2 }' | xargs kill"
List running processes, kill the selected process
.TP
.BR "git checkout $(git branch | cut -c 3- | fzy)"
.BR "git checkout $(git branch | cut \-c 3\- | fzy)"
Same as above, but switching git branches.
.SH AUTHOR
.SH AUTHORS
John Hawthorn <[email protected]>

L. Abramovich <[email protected]>
2 changes: 1 addition & 1 deletion src/bonus.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef BONUS_H
#define BONUS_H BONUS_H

#include "../config.h"
#include "config.h"

#define ASSIGN_LOWER(v) \
['a'] = (v), \
Expand Down
Loading