Compare commits

..

11 Commits
0.8.8 ... 0.8.9

Author SHA1 Message Date
Junegunn Choi
4ceb520c1d Merge pull request #115 from JackDanger/sleep-when-curses-is-unavailable
Sleep when curses is unavailable
2015-01-02 15:28:33 +09:00
Jack Danger Canty
d761ea5158 Sleep when curses is unavailable
When the curses gem is not installed and the session is running inside
tmux the user will see a flash of an opened and closed tmux pane but
will not have a chance to read the error message.
2015-01-01 22:23:37 -08:00
Junegunn Choi
7ba93d9f83 Merge pull request #113 from thedrow/patch-1
Use travis' new build workers
2014-12-29 01:03:04 +09:00
Omer Katz
b34f93f307 Use travis' new build workers
They boot faster and since we don't use root we can use them.
2014-12-28 17:11:13 +02:00
Junegunn Choi
ec040d82dd Improve word motions: ALT-B, ALT-F, ALT-D, ALT-BS (#112) 2014-12-24 13:27:39 +09:00
Junegunn Choi
00190677d4 Add support for ALT-D and ALT-BS key bindings
https://github.com/junegunn/fzf/issues/111#issuecomment-67832143
2014-12-23 12:22:19 +09:00
Junegunn Choi
d38f7a5eb5 Merge pull request #109 from brettanomyces/reorder_fish_history
Reverse the order of fish history
2014-12-13 11:10:29 +09:00
brettanomyces
ee433ef6e9 reverse history for fish shell 2014-12-13 11:54:35 +13:00
Junegunn Choi
d89c9e94ba Handle dynamically loaded completion functions (#107 / #79) 2014-12-05 00:24:25 +09:00
Junegunn Choi
7e2dfef930 Merge pull request #106 from jagajaga/master
Change `/bin/bash` to `/usr/bin/env bash`
2014-12-01 18:19:33 +09:00
Arseniy Seroka
0296fcb5cd bash -> env bash 2014-11-30 23:04:15 +03:00
6 changed files with 104 additions and 28 deletions

View File

@@ -1,4 +1,5 @@
language: ruby
sudo: false
rvm:
- "1.8.7"
- "1.9.3"

42
fzf
View File

@@ -7,7 +7,7 @@
# / __/ / /_/ __/
# /_/ /___/_/ Fuzzy finder for your shell
#
# Version: 0.8.8 (Nov 4, 2014)
# Version: 0.8.9 (Dec 24, 2014)
#
# Author: Junegunn Choi
# URL: https://github.com/junegunn/fzf
@@ -40,6 +40,7 @@ begin
require 'curses'
rescue LoadError
$stderr.puts 'curses gem is not installed. Try `gem install curses`.'
sleep 1
exit 1
end
require 'thread'
@@ -955,8 +956,10 @@ class FZF
get_mouse
end
when 'b', 98 then :alt_b
when 'd', 100 then :alt_d
when 'f', 102 then :alt_f
when :esc then :esc
when 127 then :alt_bs
else next
end if ord == 27
@@ -1012,7 +1015,20 @@ class FZF
yanked = ''
mouse_event = MouseEvent.new
backword = proc {
cursor = (input[0, cursor].rindex(/\s\S/) || -1) + 1
cursor = (input[0, cursor].rindex(/[^[:alnum:]][[:alnum:]]/) || -1) + 1
nil
}
forward = proc {
cursor += (input[cursor..-1].index(/([[:alnum:]][^[:alnum:]])|(.$)/) || -1) + 1
nil
}
rubout = proc { |regex|
pcursor = cursor
cursor = (input[0, cursor].rindex(regex) || -1) + 1
if pcursor > cursor
yanked = input[cursor...pcursor]
input = input[0...cursor] + input[pcursor..-1]
end
}
actions = {
:esc => proc { exit 1 },
@@ -1036,12 +1052,7 @@ class FZF
ctrl(:e) => proc { cursor = input.length; nil },
ctrl(:j) => proc { vselect { |v| v - @rev_dir } },
ctrl(:k) => proc { vselect { |v| v + @rev_dir } },
ctrl(:w) => proc {
pcursor = cursor
backword.call
yanked = input[cursor...pcursor] if pcursor > cursor
input = input[0...cursor] + input[pcursor..-1]
},
ctrl(:w) => proc { rubout.call /\s\S/ },
ctrl(:y) => proc { actions[:default].call yanked },
ctrl(:h) => proc { input[cursor -= 1] = '' if cursor > 0 },
ctrl(:i) => proc { |o|
@@ -1066,10 +1077,19 @@ class FZF
:del => proc { input[cursor] = '' if input.length > cursor },
:pgup => proc { vselect { |v| v + @rev_dir * (max_items - 1) } },
:pgdn => proc { vselect { |v| v - @rev_dir * (max_items - 1) } },
:alt_b => proc { backword.call; nil },
:alt_bs => proc { rubout.call /[^[:alnum:]][[:alnum:]]/ },
:alt_b => proc { backword.call },
:alt_d => proc {
pcursor = cursor
forward.call
if cursor > pcursor
yanked = input[pcursor...cursor]
input = input[0...pcursor] + input[cursor..-1]
cursor = pcursor
end
},
:alt_f => proc {
cursor += (input[cursor..-1].index(/(\S\s)|(.$)/) || -1) + 1
nil
forward.call
},
:default => proc { |val|
case val

View File

@@ -53,8 +53,25 @@ _fzf_opts_completion() {
return 0
}
_fzf_handle_dynamic_completion() {
local cmd orig ret
cmd="$1"
shift
orig=$(eval "echo \$_fzf_orig_completion_$cmd")
if [ -n "$orig" ] && type "$orig" > /dev/null 2>&1; then
$orig "$@"
elif [ -n "$_fzf_completion_loader" ]; then
_completion_loader "$@"
ret=$?
eval $(complete | \grep "\-F.* $cmd$" | _fzf_orig_completion_filter)
source $BASH_SOURCE
return $ret
fi
}
_fzf_path_completion() {
local cur base dir leftover matches trigger cmd orig
local cur base dir leftover matches trigger cmd
cmd=$(echo ${COMP_WORDS[0]} | sed 's/[^a-z0-9_=]/_/g')
COMPREPLY=()
trigger=${FZF_COMPLETION_TRIGGER:-**}
@@ -88,13 +105,12 @@ _fzf_path_completion() {
else
shift
shift
orig=$(eval "echo \$_fzf_orig_completion_$cmd")
[ -n "$orig" ] && type "$orig" > /dev/null 2>&1 && $orig "$@"
_fzf_handle_dynamic_completion "$cmd" "$@"
fi
}
_fzf_list_completion() {
local cur selected trigger cmd src ret
local cur selected trigger cmd src
read -r src
cmd=$(echo ${COMP_WORDS[0]} | sed 's/[^a-z0-9_=]/_/g')
trigger=${FZF_COMPLETION_TRIGGER:-**}
@@ -113,16 +129,7 @@ _fzf_list_completion() {
fi
else
shift
orig=$(eval "echo \$_fzf_orig_completion_$cmd")
if [ -n "$orig" ] && type "$orig" > /dev/null; then
$orig "$@"
elif [ -n "$_fzf_completion_loader" ]; then
_completion_loader "$@"
ret=$?
eval $(complete | \grep "\-F.* $cmd$" | _fzf_orig_completion_filter)
source $BASH_SOURCE
return $ret
fi
_fzf_handle_dynamic_completion "$cmd" "$@"
fi
}

12
install
View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
cd `dirname $BASH_SOURCE`
fzf_base=`pwd`
@@ -294,8 +294,16 @@ function fzf_key_bindings
rm -f $TMPDIR/fzf.result
end
function __fzf_reverse
if which tac > /dev/null
tac $argv
else
tail -r $argv
end
end
function __fzf_ctrl_r
history | fzf +s +m > $TMPDIR/fzf.result
history | __fzf_reverse | fzf +s +m > $TMPDIR/fzf.result
and commandline (cat $TMPDIR/fzf.result)
commandline -f repaint
rm -f $TMPDIR/fzf.result

View File

@@ -50,6 +50,7 @@ class MockTTY
@buffer << str
@condv.broadcast
end
self
end
end
@@ -805,6 +806,45 @@ class TestFZF < MiniTest::Unit::TestCase
tty << "\e[Z\e[Z"
tty << "\r"
end
# ALT-D
assert_fzf_output %w[--print-query], "", "hello baby = world" do |tty|
tty << "hello world baby"
tty << alt(:b) << alt(:b) << alt(:d)
tty << ctrl(:e) << " = " << ctrl(:y)
tty << "\r"
end
# ALT-BACKSPACE
assert_fzf_output %w[--print-query], "", "hello baby = world " do |tty|
tty << "hello world baby"
tty << alt(:b) << alt(127.chr)
tty << ctrl(:e) << " = " << ctrl(:y)
tty << "\r"
end
# Word-movements
assert_fzf_output %w[--print-query], "", "ello!_orld!~ foo=?" do |tty|
tty << "hello_world==baby?"
tty << alt(:b) << ctrl(:d)
tty << alt(:b) << ctrl(:d)
tty << alt(:b) << ctrl(:d)
tty << alt(:f) << '!'
tty << alt(:f) << '!'
tty << alt(:d) << '~'
tty << " foo=bar foo=bar"
tty << ctrl(:w)
tty << alt(127.chr)
tty << "\r"
end
end
def alt chr
"\e#{chr}"
end
def ctrl char
char.to_s.ord - 'a'.ord + 1
end
end

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
confirm() {
while [ 1 ]; do