m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-14 14:23:47 -05:00

Compare commits

...

4 Commits
0.8.0 ... 0.8.1

Author SHA1 Message Date
Junegunn Choi
ae84d8c7a4 Update README 2014-03-09 11:52:35 +09:00
Junegunn Choi
dbd627c38a Update README: Remove section on --disable-gems
This is automatically set in install script. It may only cause unnecessary
confusion.
2014-03-09 10:46:34 +09:00
Junegunn Choi
d172c3ce03 Update README 2014-03-09 10:43:59 +09:00
Junegunn Choi
9904f5354e Add --black for terminals incapable of use_default_colors
See the discussion in #18.

Use --black option to use black background regardless of the default
background color of the terminal. Also, this option can be used to fix
rendering issues on terminals that don't support use_default_colors (man
3 default_colors). Depending on the terminal, use_default_colors may or
may not succeed, but the Ruby version of it always returns nil, it's
currently not possible to automatically enable this option.
2014-03-09 04:09:09 +09:00
4 changed files with 28 additions and 33 deletions

View File

@@ -59,6 +59,7 @@ usage: fzf [options]
+i Case-sensitive match +i Case-sensitive match
+c, --no-color Disable colors +c, --no-color Disable colors
+2, --no-256 Disable 256-color +2, --no-256 Disable 256-color
--black Use black background
--no-mouse Disable mouse --no-mouse Disable mouse
Environment variables Environment variables
@@ -290,34 +291,20 @@ a very large list of files, fzf is significantly faster and it does not block.
Tips Tips
---- ----
### Faster startup with `--disable-gems` options ### Rendering issues
If you're running Ruby 1.9 or above, you can improve the startup time with If you have any rendering issues, check the followings:
`--disable-gems` option to Ruby.
- `time ruby ~/bin/fzf -h` 1. Make sure `$TERM` is correctly set. fzf will use 256-color only if it
- 0.077 sec contains `256` (e.g. `xterm-256color`)
- `time ruby --disable-gems ~/bin/fzf -h` 2. If you're on screen or tmux, `$TERM` should be either `screen` or
- 0.025 sec `screen-256color`
3. Some terminal emulators (e.g. mintty) have problem displaying default
You can define fzf function with the option as follows: background color and make some text unable to read. In that case, try `--black`
option. And if it solves your problem, I recommend including it in
```sh `FZF_DEFAULT_OPTS` for further convenience.
fzf() { 4. If you still have problem, try `--no-256` option or even `--no-color`.
ruby --disable-gems ~/bin/fzf "$@" 5. Ruby 1.9 or above is required for correctly displaying unicode characters.
}
export -f fzf
```
However, this is automatically set up in your .bashrc and .zshrc if you use the
bundled [install](https://github.com/junegunn/fzf/blob/master/install) script.
### Incorrect display on Ruby 1.8
It is reported that the output of fzf can become unreadable on some terminals
when it's running on Ruby 1.8. If you experience the problem, upgrade your Ruby
to 1.9 or above. Ruby 1.9 or above is also required for displaying Unicode
characters.
### Ranking algorithm ### Ranking algorithm

10
fzf
View File

@@ -7,7 +7,7 @@
# / __/ / /_/ __/ # / __/ / /_/ __/
# /_/ /___/_/ Fuzzy finder for your shell # /_/ /___/_/ Fuzzy finder for your shell
# #
# Version: 0.8.0 (March 8, 2014) # Version: 0.8.1 (March 9, 2014)
# #
# Author: Junegunn Choi # Author: Junegunn Choi
# URL: https://github.com/junegunn/fzf # URL: https://github.com/junegunn/fzf
@@ -50,7 +50,7 @@ end
class FZF class FZF
C = Curses C = Curses
attr_reader :rxflag, :sort, :color, :ansi256, :mouse, :multi, :query, :filter, :extended attr_reader :rxflag, :sort, :color, :black, :ansi256, :mouse, :multi, :query, :filter, :extended
class AtomicVar class AtomicVar
def initialize value def initialize value
@@ -78,6 +78,7 @@ class FZF
@sort = ENV.fetch('FZF_DEFAULT_SORT', 1000).to_i @sort = ENV.fetch('FZF_DEFAULT_SORT', 1000).to_i
@color = true @color = true
@ansi256 = true @ansi256 = true
@black = false
@multi = false @multi = false
@mouse = true @mouse = true
@extended = nil @extended = nil
@@ -104,6 +105,8 @@ class FZF
when '+c', '--no-color' then @color = false when '+c', '--no-color' then @color = false
when '-2', '--256' then @ansi256 = true when '-2', '--256' then @ansi256 = true
when '+2', '--no-256' then @ansi256 = false when '+2', '--no-256' then @ansi256 = false
when '--black' then @black = true
when '--no-black' then @black = false
when '--mouse' then @mouse = true when '--mouse' then @mouse = true
when '--no-mouse' then @mouse = false when '--no-mouse' then @mouse = false
when '+s', '--no-sort' then @sort = nil when '+s', '--no-sort' then @sort = nil
@@ -211,6 +214,7 @@ class FZF
+i Case-sensitive match +i Case-sensitive match
+c, --no-color Disable colors +c, --no-color Disable colors
+2, --no-256 Disable 256-color +2, --no-256 Disable 256-color
--black Use black background
--no-mouse Disable mouse --no-mouse Disable mouse
Environment variables Environment variables
@@ -517,7 +521,7 @@ class FZF
C.mousemask C::ALL_MOUSE_EVENTS if @mouse C.mousemask C::ALL_MOUSE_EVENTS if @mouse
C.start_color C.start_color
dbg = dbg =
if C.respond_to?(:use_default_colors) if !@black && C.respond_to?(:use_default_colors)
C.use_default_colors C.use_default_colors
-1 -1
else else

View File

@@ -1,7 +1,7 @@
# coding: utf-8 # coding: utf-8
Gem::Specification.new do |spec| Gem::Specification.new do |spec|
spec.name = 'fzf' spec.name = 'fzf'
spec.version = '0.8.0' spec.version = '0.8.1'
spec.authors = ['Junegunn Choi'] spec.authors = ['Junegunn Choi']
spec.email = ['junegunn.c@gmail.com'] spec.email = ['junegunn.c@gmail.com']
spec.description = %q{Fuzzy finder for your shell} spec.description = %q{Fuzzy finder for your shell}

View File

@@ -28,7 +28,7 @@ class TestFZF < MiniTest::Unit::TestCase
fzf = FZF.new [] fzf = FZF.new []
assert_equal 20000, fzf.sort assert_equal 20000, fzf.sort
ENV['FZF_DEFAULT_OPTS'] = '-x -m -s 10000 -q " hello world " +c +2 --no-mouse -f "goodbye world"' ENV['FZF_DEFAULT_OPTS'] = '-x -m -s 10000 -q " hello world " +c +2 --no-mouse -f "goodbye world" --black'
fzf = FZF.new [] fzf = FZF.new []
assert_equal 10000, fzf.sort assert_equal 10000, fzf.sort
assert_equal ' hello world ', assert_equal ' hello world ',
@@ -39,6 +39,7 @@ class TestFZF < MiniTest::Unit::TestCase
assert_equal true, fzf.multi assert_equal true, fzf.multi
assert_equal false, fzf.color assert_equal false, fzf.color
assert_equal false, fzf.ansi256 assert_equal false, fzf.ansi256
assert_equal true, fzf.black
assert_equal false, fzf.mouse assert_equal false, fzf.mouse
end end
@@ -50,6 +51,7 @@ class TestFZF < MiniTest::Unit::TestCase
assert_equal true, fzf.multi assert_equal true, fzf.multi
assert_equal false, fzf.color assert_equal false, fzf.color
assert_equal false, fzf.ansi256 assert_equal false, fzf.ansi256
assert_equal false, fzf.black
assert_equal false, fzf.mouse assert_equal false, fzf.mouse
assert_equal 0, fzf.rxflag assert_equal 0, fzf.rxflag
assert_equal 'hello', fzf.query.get assert_equal 'hello', fzf.query.get
@@ -57,12 +59,13 @@ class TestFZF < MiniTest::Unit::TestCase
assert_equal :exact, fzf.extended assert_equal :exact, fzf.extended
fzf = FZF.new %w[--sort=2000 --no-color --multi +i --query hello fzf = FZF.new %w[--sort=2000 --no-color --multi +i --query hello
--filter a --filter b --no-256 --filter a --filter b --no-256 --black
--no-sort -i --color --no-multi --256] --no-sort -i --color --no-multi --256]
assert_equal nil, fzf.sort assert_equal nil, fzf.sort
assert_equal false, fzf.multi assert_equal false, fzf.multi
assert_equal true, fzf.color assert_equal true, fzf.color
assert_equal true, fzf.ansi256 assert_equal true, fzf.ansi256
assert_equal true, fzf.black
assert_equal true, fzf.mouse assert_equal true, fzf.mouse
assert_equal 1, fzf.rxflag assert_equal 1, fzf.rxflag
assert_equal 'b', fzf.filter assert_equal 'b', fzf.filter
@@ -82,11 +85,12 @@ class TestFZF < MiniTest::Unit::TestCase
# Left-to-right # Left-to-right
fzf = FZF.new %w[-s 2000 +c -m +i -qhello -x -fgoodbye +2 fzf = FZF.new %w[-s 2000 +c -m +i -qhello -x -fgoodbye +2
-s 3000 -c +m -i -q world +x -fworld -2] -s 3000 -c +m -i -q world +x -fworld -2 --black --no-black]
assert_equal 3000, fzf.sort assert_equal 3000, fzf.sort
assert_equal false, fzf.multi assert_equal false, fzf.multi
assert_equal true, fzf.color assert_equal true, fzf.color
assert_equal true, fzf.ansi256 assert_equal true, fzf.ansi256
assert_equal false, fzf.black
assert_equal 1, fzf.rxflag assert_equal 1, fzf.rxflag
assert_equal 'world', fzf.query.get assert_equal 'world', fzf.query.get
assert_equal 'world', fzf.filter assert_equal 'world', fzf.filter