diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2015-06-14 12:25:08 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-06-14 12:25:08 +0900 |
| commit | 6c99cc1700fda0c04500ee03b7e5f3ca22c7710c (patch) | |
| tree | a6a671d49f562937a50d15c7439fe7682e7033d5 /src/options_test.go | |
| parent | fe5b190a7d8612bb90de272d26470bd02dc76a64 (diff) | |
| download | fzf-6c99cc1700fda0c04500ee03b7e5f3ca22c7710c.tar.gz | |
Add bind action for executing arbitrary command (#265)
e.g. fzf --bind "ctrl-m:execute(less {})"
fzf --bind "ctrl-t:execute[tmux new-window -d 'vim {}']"
Diffstat (limited to 'src/options_test.go')
| -rw-r--r-- | src/options_test.go | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/options_test.go b/src/options_test.go index d3562108..91e3754b 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -136,11 +136,19 @@ func TestBind(t *testing.T) { t.Errorf("%d != %d", action, expected) } } + checkString := func(action string, expected string) { + if action != expected { + t.Errorf("%d != %d", action, expected) + } + } keymap := defaultKeymap() + execmap := make(map[int]string) check(actBeginningOfLine, keymap[curses.CtrlA]) - keymap, toggleSort := - parseKeymap(keymap, false, - "ctrl-a:kill-line,ctrl-b:toggle-sort,c:page-up,alt-z:page-down") + keymap, execmap, toggleSort := + parseKeymap(keymap, execmap, false, + "ctrl-a:kill-line,ctrl-b:toggle-sort,c:page-up,alt-z:page-down,"+ + "f1:execute(ls {}),f2:execute/echo {}, {}, {}/,f3:execute[echo '({})'],f4:execute:less {}:,"+ + "alt-a:execute@echo (,),[,],/,:,;,%,{}@,alt-b:execute;echo (,),[,],/,:,@,%,{};") if !toggleSort { t.Errorf("toggleSort not set") } @@ -148,8 +156,18 @@ func TestBind(t *testing.T) { check(actToggleSort, keymap[curses.CtrlB]) check(actPageUp, keymap[curses.AltZ+'c']) check(actPageDown, keymap[curses.AltZ]) - - keymap, toggleSort = parseKeymap(keymap, false, "f1:abort") + check(actExecute, keymap[curses.F1]) + check(actExecute, keymap[curses.F2]) + check(actExecute, keymap[curses.F3]) + check(actExecute, keymap[curses.F4]) + checkString("ls {}", execmap[curses.F1]) + checkString("echo {}, {}, {}", execmap[curses.F2]) + checkString("echo '({})'", execmap[curses.F3]) + checkString("less {}", execmap[curses.F4]) + checkString("echo (,),[,],/,:,;,%,{}", execmap[curses.AltA]) + checkString("echo (,),[,],/,:,@,%,{}", execmap[curses.AltB]) + + keymap, execmap, toggleSort = parseKeymap(keymap, execmap, false, "f1:abort") if toggleSort { t.Errorf("toggleSort set") } |
