Add --no-color (+c) option
This commit is contained in:
parent
c326e363eb
commit
8e305edcf2
@ -73,6 +73,7 @@ usage: fzf [options]
|
||||
-s, --sort=MAX Maximum number of matched items to sort. Default: 500
|
||||
+s, --no-sort Keep the sequence unchanged.
|
||||
+i Case-sensitive match
|
||||
+c, --no-color Disable colors
|
||||
```
|
||||
|
||||
fzf will launch curses-based finder, read the list from STDIN, and write the
|
||||
|
22
fzf
22
fzf
@ -40,7 +40,8 @@ def usage x
|
||||
|
||||
-s, --sort=MAX Maximum number of matched items to sort. Default: 500.
|
||||
+s, --no-sort Do not sort the result. Keep the sequence unchanged.
|
||||
+i Case-sensitive match]
|
||||
+i Case-sensitive match
|
||||
+c, --no-color Disable colors]
|
||||
exit x
|
||||
end
|
||||
|
||||
@ -50,6 +51,7 @@ $stdout.reopen($stderr)
|
||||
usage 0 unless (%w[--help -h] & ARGV).empty?
|
||||
@rxflag = ARGV.delete('+i') ? 0 : Regexp::IGNORECASE
|
||||
@sort = (ARGV.delete('+s') || ARGV.delete('--no-sort')) ? nil : 500
|
||||
@color = (ARGV.delete('+c') || ARGV.delete('--no-color')).nil?
|
||||
rest = ARGV.join ' '
|
||||
if sort = rest.match(/(-s|--sort=?) ?([0-9]+)/)
|
||||
usage 1 unless @sort
|
||||
@ -132,7 +134,7 @@ when /darwin/
|
||||
ret << c
|
||||
end
|
||||
end
|
||||
return [ret, omap[b] || 0, omap[e] || (omap.last || 0 + 1)]
|
||||
return [ret, omap[b] || 0, omap[e] || ((omap.last || 0) + 1)]
|
||||
end
|
||||
end
|
||||
|
||||
@ -260,6 +262,8 @@ dbg =
|
||||
end
|
||||
C.raw
|
||||
C.noecho
|
||||
|
||||
if @color
|
||||
if C.can_change_color?
|
||||
fg = ENV.fetch('FZF_FG', 252).to_i
|
||||
bg = ENV.fetch('FZF_BG', 236).to_i
|
||||
@ -285,6 +289,20 @@ def color sym, bold = false
|
||||
:match!, :fan, :info, :red].index(sym) + 1) |
|
||||
(bold ? C::A_BOLD : 0)
|
||||
end
|
||||
else
|
||||
def color sym, bold = false
|
||||
case sym
|
||||
when :chosen
|
||||
bold ? C::A_REVERSE : 0
|
||||
when :match
|
||||
C::A_UNDERLINE
|
||||
when :match!
|
||||
C::A_REVERSE | C::A_UNDERLINE
|
||||
else
|
||||
0
|
||||
end | (bold ? C::A_BOLD : 0)
|
||||
end
|
||||
end
|
||||
|
||||
@read =
|
||||
if $stdin.tty?
|
||||
|
Loading…
Reference in New Issue
Block a user