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