Giter Club home page Giter Club logo

selecta's Introduction

Selecta

Selecta is a fuzzy selector. You can use it for fuzzy selection in the style of Command-T, ctrlp, etc. You can also use it to fuzzy select anything else: command names, help topics, identifiers; anything you have a list of.

It was originally written to select things from vim, but it has no dependency on vim at all and is used for many other purposes. Its interface is dead simple:

  • Pass it a list of choices on stdin.
  • It will present a pretty standard fuzzy selection interface to the user (and block until they make a selection or kill it with ^C).
  • It will print the user's selection on stdout.

For example, you can say:

cat $(ls *.txt | selecta)

which will prompt the user to fuzzy-select one of the text files in the current directory, then print the contents of whichever one they choose. It looks like this:

Demo

Selecta supports these keys:

  • ^W to delete the word before the cursor
  • ^H to delete the character before the cursor
  • ^U to delete the entire line
  • ^N to select the next match
  • ^P to select the previous match
  • ^C to quit without selecting a match

Theory of Operation

Selecta is unusual in that it's a filter (it reads from/to stdin/stdout), but it's also an interactive program (it accepts user keystrokes and draws a UI). It directly opens /dev/tty to do the latter.

With that exception aside, Selecta is a normal, well-behaved Unix tool. If a selection is made, the line will be written to stdout with a single trailing newline. If no selection is made (meaning the user killed Selecta with ^C), it will write nothing to stdout and exit with status code 1.

Because it's just a filter program, Selecta doesn't know about any other tools. Specifically, it does not:

  • Read from or write to the disk.
  • Know about any editors (including vim).
  • Know what it's searching.
  • Perform any actions on the item you select.

The ranking algorithm is:

  • Select each input string that contains all of the characters in the query. They must be in order, but don't have to be sequential. Case is ignored.
  • The score is the length of the matching substring. Lower is better.
  • If a character is on a word boundary, it only contributes 1 to the length, rather than the actual number of characters since the previous matching character. Querying "app/models" for "am" gives a score of 2, not 5.
  • Bonus for exact queries: when several adjacent characters match sequentially, only the first two score. Querying "search_spec.rb" for "spec" gives a score of 2, not 4.
  • Bonus for acronyms: when several sequential query characters exist on word boundaries, only the first two score. Querying "app/models/user.rb" for "amu" gives a score of 2, not 3.

Some concrete examples:

  • "ct" will match "cat" and "Crate", but not "tack".
  • "le" will match "lend" and "ladder". "lend" will appear higher in the results because the matching substring is shorter ("le" vs. "ladde").

Installation

Selecta requires Ruby 1.9.3 or better.

To install on your Mac using Homebrew, say:

brew install selecta

For other systems, copy the selecta script to your path. ~/bin is a great place for it. If you don't currently have a ~/bin, just do mkdir ~/bin and add export PATH="$HOME/bin:$PATH" to your .zshrc, .bashrc, etc.

Selecta is not installable as a Ruby gem! Gems are only good for application-specific tools. You want Selecta available at all times. If it were a gem, it would sometimes disappear when switching Rubies, gemsets, etc.

Use with Vim

There's no vim plugin. It may not end up needing one; we'll see. For now, you can just stick the code below in your .vimrc to invoke Selecta with <leader>f (this will be \f unless you've changed your leader). Note that Selecta has to run in a terminal by its nature, so this Vim example will not work in graphical Vims like MacVim.

" Run a given vim command on the results of fuzzy selecting from a given shell
" command. See usage below.
function! SelectaCommand(choice_command, selecta_args, vim_command)
  try
    let selection = system(a:choice_command . " | selecta " . a:selecta_args)
  catch /Vim:Interrupt/
    " Swallow the ^C so that the redraw below happens; otherwise there will be
    " leftovers from selecta on the screen
    redraw!
    return
  endtry
  redraw!
  exec a:vim_command . " " . selection
endfunction

" Find all files in all non-dot directories starting in the working directory.
" Fuzzy select one of those. Open the selected file with :e.
nnoremap <leader>f :call SelectaCommand("find * -type f", "", ":e")<cr>

Usage Examples

For other examples of using Selecta with Vim, git, zsh, etc., see the examples file. It has pre-built configurations for many use cases.

FAQ

Won't this be slow?

Nope: startup and termination together burn about 23 ms of CPU on my machine (a mid-2011 MacBook Air). For under 100,000 lines of input or so, searching is quite snappy, and you'll rarely want to search through more than that. On modern machines, finding files is also quite fast: find on a 100,000-file directory takes about 200 ms on my machine.

What about caching, selecting only certain file types, etc.?

Those are different problems. This is just a simple fuzzy finding user interface. It could be combined with caching, etc. I don't use caching myself, prefering to keep repos small. Selecta was partially motivated by frustration with existing fuzzy file finders, which occasionally showed incorrect results with caching turned on but were painfully slow with caching disabled.

selecta's People

Contributors

amichaelc avatar arronmabrey avatar ckeschnat avatar dlee avatar garybernhardt avatar ggilder avatar gshutler avatar mavcunha avatar michaelavila avatar rschmitt avatar sos4nt avatar stbenjam avatar teoljungberg avatar untitaker avatar zakj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

selecta's Issues

Selecta could/should allow use of up/down arrows

Not sure if this is entirely within scope, but I think it would be quite natural:

When running selecta, allow up/down key presses to navigate up/down the list of displayed items. Useful to pop "down" one or two, and press enter to select.

HTH

Optimize matching

Just opening this as a reminder from #51. I started to look at rebasing my commit but then I figured if the algorithm is changing a lot it will end up being unusable anyway.

So for the future, the two performance improvements I implemented in f695810 were:

  • Don't re-score eliminated choices when appending to query — effectively, Search would maintain a list of "choices" and "candidates" — candidates being choices that match the query. When appending to a query, Search would pass along the existing list of candidates so that the new query can be run over a smaller list.
  • Cache previously calculated character indexes on choices — this may not apply depending on changes to the scoring algorithm, but basically calculate and cache character indexes on each choice (in my commit, done by introducing a new Choice object) so that they don't have to be recalculated on each pass. Not sure how this could be incorporated while keeping the "functional core" concept, however.

Coloring matched portion?

Favourite aspect of ag / ack is how they colour the matched portion. Thoughts on adding this to selecta?

screenshot 2015-01-05 09 29 59

use within zsh causing TTY output to shift to bottom of screen

After watching Joe Armstrong's "The Mess We're In" talk from Strangeloop, I'm aware this is possibly caused by custom config specific to my machine, but I figured I'd post in hopes that it's an obvious fix to someone.

Using your demo script for project selection: cd $(find ~/src -maxdepth 1 -type d | selecta), the output does the following in a zsh terminal:

image

Is there a way to keep the output from jumping to the bottom of the terminal and, once a selection is made, to have the next line happen underneath the line selecta was called from?

Scoring algorithm needs improvement

Beginning of words should get ranked before the ones containing a letter.
For example:

  • searching with just a character f:
    • Given there's Gemfile, some_other_file, lib/xcpretty/formatter.rb
    • formatter.rb should appear on top of the list

If it means anything, this is how TextMate's CMD+T behaves.

Using selecta multiple times in one pipeline doesn't work

I'd like to wire up more than one selecta in a pipeline. Here's a contrived example:

$ cat findword
#!/bin/sh
read letter && grep "^$letter" /usr/share/dict/words
$ printf '%s\n' a b c d e | selecta | ./findword | selecta

So, I would use the first selecta to pick a letter, then output that to another script which generates more choices, and use the second selecta to pick a word from those. (In reality, these would be network queries or something else non-trivial.)

The first selecta works normally, but the second one does not. The list of choices doesn't update until I press enter, and then pressing enter repeatedly causes the cursor to quickly jump to the highlighted word and back to the input line, without exiting. I can press ^C to exit without any output, but that's it.

I'm guessing this has to do with how the TTY is reopened after stdin/stdout have already been redirected by the pipeline, but I don't know enough about how that works.

Exitstatus 0 when aborting with Ctrl-C

I just tried writing a tiny script with selecta and noted that the exitstatus is 0 even though I abort it with Ctrl-C. Since the behavior of exiting with 1 is explicitly mentioned in the README, I'm assuming this is a bug.

I'm trying with the latest version of selecta, and my rubby version is ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]. I've also tried on a couple of other machines and rubbies, with the same result.

Invalid argument 'dsusp' under Ubuntu 13.04 - stty 8.20

> stty -F /dev/tty raw -echo cbreak dsusp undef
stty: invalid argument ‘dsusp’

Tried tracing this issue, but the option is listed under man stty 8.20, got stuck. Got any pointers?

Special characters:
    * dsusp CHAR
           CHAR will send a terminal stop signal once input flushed

Suggested vim function does not work on MacVim

When following the instructions on the README for using selecta with vim, I get the following error when using MacVim:

E79: Cannot expand wildcards
"~/bin/selecta:546:in `initialize': Device not configured - /dev/tty (Errno::ENXIO)" [New DIRECTORY]
Error detected while processing function SelectaCommand:
line   10:
E492: Not an editor command: ^Ifrom /Users/dlee/bin/selecta:546:in `open'^@^Ifrom /Users/dlee/bin/selecta:546:in `with_tty'^@^Ifrom /Users/dlee/bin/selecta:321:in `with_screen'^@^Ifrom /Use
rs/dlee/bin/selecta:36:in `main'^@^Ifrom /Users/dlee/bin/selecta:586:in `<main>'^@

stty 8.21

stty 8.21 doesn't have -f, only -F.

command("stty -f #{out_file.path} #{args}")

fails.

command("stty -F #{out_file.path} #{args}")

works.

Vim example doesn't work in MacVim

I pasted the SelectaCommand function from the README into my vimrc, along with the corresponding nnoremap. It works as expected in terminal Vim.

Regrettably it doesn't work in MacVim. I know you don't use MacVim and so may not be overly wracked with worry, but I just thought I'd mention it in case.

screen shot 2013-10-23 at 12 29 59

This is on MacVim snapshot 71 (i.e. vim 7.4 p1-22), selecta current master (50190f5), bash.

`*': negative argument (ArgumentError)

in write_text_object:
remaining_cols gets negative when printed string is longer than the terminal.
" " * remaining_cols does not seem to like that.

consider us poor npm users!

$ less $(find . -type f -name "*.html"|selecta)
> sock
./project/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/examples/serverstats/public/index.htm
l/project2/some_other_file  ###  notice the l from .html wrapping around ###
/home/user/bin/selecta:258:in `*': negative argument (ArgumentError)                                                  
./particfrom /home/user/bin/selecta:258:in `write_text_object'                                                        
./cfstrafrom /home/user/bin/selecta:236:in `write_unrestricted'                                                       
    from /home/user/bin/selecta:231:in `write'
    from /home/user/bin/selecta:225:in `block in write_lines'
    from /home/user/bin/selecta:224:in `each'
    from /home/user/bin/selecta:224:in `each_with_index'
    from /home/user/bin/selecta:224:in `write_lines'
    from /home/user/bin/selecta:122:in `block in render!'
    from /home/user/bin/selecta:196:in `call'
    from /home/user/bin/selecta:196:in `with_cursor_hidden'
    from /home/user/bin/selecta:121:in `render!'
    from /home/user/bin/selecta:22:in `block in main'
    from /home/user/bin/selecta:154:in `block in with_screen'
    from /home/user/bin/selecta:361:in `call'
    from /home/user/bin/selecta:361:in `block (2 levels) in with_tty'
    from /home/user/bin/selecta:359:in `open'
    from /home/user/bin/selecta:359:in `block in with_tty'
    from /home/user/bin/selecta:358:in `open'
    from /home/user/bin/selecta:358:in `with_tty'
    from /home/user/bin/selecta:150:in `with_screen'
    from /home/user/bin/selecta:17:in `main'
    from /home/user/bin/selecta:393:in `<main>'
Missing filename ("less --help" for help)
$ 

Should we keep the new boundary-aware scoring algorithm?

I've made the scoring algorithm smarter about sequential matching characters and word boundaries (to improve results when querying for acronyms). It's merged to master, along with some other changes, in d874c99. The README contains a summary (search it for "algorithm").

I'd love to hear feedback from actual Selecta users, especially after you've used it on actual projects.

--search broken on master

$ echo -e "foo\nbar\nbaz\nquux" | selecta --search ba
4 > ba
foo
bar
baz
quux

Typing to alter the search text works as expected, it seems to just be the initial state.

Match count label

I enjoy using selecta for file/buffer opening in vim. But I would like the match count label to be optional.

Specifically this line:

selecta/selecta

Line 354 in 8135e72

search_line = "#{match_count_label} > " + search.query
where it outputs the number of matched lines in front of the input.

I have been using it for a while on my laptop where I didn't notice it - I only just saw it as I installed it on my desktop, so I guess it's a new addition.

License?

I didn't see a license in the README or the repo. Is it open source?

Are you open to sorting the fuzzy matches?

The README states that Selecta doesn't change the order of items piped in. Is this a hard and fast constraint?

I ask because I use Selecta to find files and it would be nice (for me, at least) for Selecta to sort matches by some metric of goodness of fit. For example, prioritising matches where the match includes the first letter of each path component (a/c/... hits app/controllers/... before app/helpers/search_helper.)

Quite possibly everybody would have a different idea of how they would like to sort matches so maybe this is a non-starter.

Uncaught exception when not in a terminal

If someone runs Selecta from MacVim (e.g., #31), they currently get an uncaught exception because /dev/tty isn't accessible. We should catch that exception internally, or otherwise detect the lack of a terminal, and then show a nice error message.

^N and ^P not working on OS X 10.9

I'm using ZSH as my shell.
When I launch ls | selecta I get half screen empty space and then the selecta prompt pops up, when searching for a file I am unable to select any of the matches.

What information do you need to debug this?

No proper rendering if visible choices is greater than available screen height

I've stumbled on this one when splitting iTerm2 screens. When visible choices is greater than screen height the rendering gets truncated, typing to select scrambles the screen.

image

Forcing visible choices to be constrained by screen.height ([screen.height -2] so it fits nicely) fix the truncation.

diff --git a/selecta b/selecta
index 4c96376..662ec1b 100755
--- a/selecta
+++ b/selecta
@@ -41,6 +41,8 @@ class Selecta
   # Initialize the screen (and tear it down properly when done).
   def run_in_screen(config, search)
     Screen.with_screen do |screen, tty|
+      config.visible_choices = config.visible_choices > screen.height - 2 ? screen.height - 2 : config.visible_choices
+
       # We emit the number of lines we'll use later so we don't clobber whatever
       # was already on the screen.
       config.visible_choices.times { tty.puts }

Environment:
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
iTerm2 Build 1.0.0.20131116
OSX 10.9.1 (Mavericks)

Non-interactive mode?

As far as I understand, selecta currently requires a tty. However, it might also be useful to just have a sort of fuzzy-grep.
In my case I have a script which yields a list of urls, and I want to get a list of urls (fuzzy) matching a string ordered by score.

About getting control characters (KEY_* constants)

# I don't know how to get these key codes other than by hard-coding the
# ordinals

\c or \C- can be used (not sure about JRuby but Rubinius and CRuby - of course - support them):

KEY_CTRL_C = ?\cC
KEY_CTRL_N = ?\C-n
KEY_CTRL_P = "\cp"
KEY_CTRL_W = "\C-W"
KEY_DELETE = ?\c?

Praise Perl's influence on Ruby!

(Well, or don't.)

Error: Ruby 1.9 or better requirement

I am using RVM to manage my Ruby version. I am currently using Ruby 2.0 and have it set as default. When I run 'brew install selecta', the following error is returned:

selecta: Selecta requires Ruby 1.9 or better.
Error: An unsatisfied requirement failed this build.

This behavior is the same even if I switch to a new ruby version such as 2.1.

Combination of umlauts and tabs breaks selecta's UI

The following command:

python -c '[print("ä\t" * 200) for i in range(20)]' | selecta

looks like this:

2015-02-01-133529_488x237_scrot

When I start typing, the cursor is still somewhere inbetween the suggestions:

2015-02-01-133550_349x171_scrot

Functionality-wise selecta works fine. This seems to occur only when the available suggestions exceed the screen's height.

This also occurs under zsh :P

Highlight matching string

ctrlp.vim (and probably other fuzzies) highlight the matching substring with colors:
ctrlp

I like this since it gives fast visual feedback over what's matching. This is especially useful if you make a mistake, since you can deduce if you did something wrong directly while looking at the result.

Would this be a nice feature for selecta too?

Keyboard input issues after integrating with Vim 7.4.430?

Using Selecta with Vim is buggy for me after upgrading to Vim 7.4.430, though I don't have enough information to rule out a coincidence.

Behavior

  • Keyboard input is now extremely sluggish. The display often takes near a second to sync.
  • All control-keys with the exception of ^C have stopped working, i.e. they do nothing.
  • Pressing the backspace key also does nothing.

Setup

I am integrating Selecta with Vim as suggested in the README:

function! SelectaCommand(choice_command, selecta_args, vim_command)
  try
    silent let selection = system(a:choice_command . " | selecta " . a:selecta_args)
  catch /Vim:Interrupt/
    " Swallow the ^C so that the redraw below happens; otherwise there will be
    " leftovers from selecta on the screen
    redraw!
    return
  endtry
  redraw!
  exec a:vim_command . " " . selection
endfunction

nnoremap <leader>p :call SelectaCommand("find * -type f", "", ":e")<cr>

Selecta

I am running 8179c87.

Vim

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep  2 2014 09:11:05)
MacOS X (unix) version
Included patches: 1-430
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         -gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -F/usr/local/Frameworks -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.9 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang   -L. -L/Users/user/.rbenv/versions/2.1.2/lib  -fstack-protector -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector -L/usr/local/lib  -L/System/Library/Perl/5.16/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby-static -framework CoreFoundation -lgmp -lobjc -L/Users/user/.rbenv/versions/2.1.2/lib

I am running OS X 10.9.4.

Arrow keys type `OA`, `OB`, `OC`, and `OD`

In this screenshot I've typed search and pressed the down arrow twice.
screenshot 2015-02-03 16 21 59

Using OS X 10.10.2. Happens in both iTerm 2.0.0.20141103 (terminal type is xterm-256color) and Terminal 2.5.1 (343.6) (tried with terminal types xterm, xterm-256color, and rxvt. ansi changes the charcters to [A, [B, [C, and [D).

Is my terminal configured wrong?

Alternative to Ctr-c

At the moment, if I want to get out the selecta prompt (essantially cancelling the search), I have to press Ctrl-c. That is often tedious. It would be better is I could get out of selecta by pressing Esc, or even Enter when no search query has been entered; That assumes that no search result is pre-selected.

Use input directly

I think it would be quite useful if selecta had a bind that use what the user currently has entered, like Control+Enter or Shift+Enter or something.

This would mean given a list with abcd present, if the user types abc and hit said bind, abc would be passed through as the result even though abcd was highlighted.

This would let users select things that are not in the list if applicable to their situation.

Selecting with no matches raises an exception

Run selecta, type a query that matches nothing, hit enter:

/Users/grb/bin/selecta:143:in `fetch': index 0 outside of array bounds: 0...0 (IndexError)
    from /Users/grb/bin/selecta:143:in `selected_choice'
    from /Users/grb/bin/selecta:35:in `main'
    from /Users/grb/bin/selecta:490:in `<main>'

selecta should start UI before stdin is completely consumed

Currently, selecta appears to wait until all input is read before showing any UI. It seems like it would be beneficial on large trees if selecta could start early, and incrementally add files to its set as it reads them (maybe in chunks of time / number of files so it doesn't have to recompute on every line). This might make for a jumpier UI, but would dramatically speed up the UI when the input file set is large, and would allow the user to start typing earlier.

No selection for selected entry

Is it just me or is there something missing?
I can select different entries with ^N and ^P but I don't see it.
2013-10-15-223151_586x208_scrot

I use ArchLinux with urxvt.

'Colorful' input produces broken output

Hello. Thank you very much for your awesome work!
But if we add color to one of your examples, things get a little bit broken:

$ git branch --color=always | cut -c 3- | selecta | xargs git checkout
> mas
master 


error: pathspec 'master' did not match any file(s) known to git.

Thank you once again, and could we potentially have line selection with arrow keys? That would be a very nice feature.

Versions seem wrong.

Selecta says its version is 0.0.2

> ag VERSION.\*=
> ./selecta  --version

Homebrew says it is 0.0.3

> brew info selecta | ag \\d\\.\\d\\.\\d

There is a tag for 0.0.3 with 42 commits on HEAD since then

> git tag
> git log v0.0.3^..HEAD --format='%C(yellow)%h%Cred%d%Creset %s '

screenshot 2015-01-05 10 21 09

selecta broken on 10.9 (Mavericks)?

Hi,

Using the vim snippet from the README file:

" Run a given vim command on the results of fuzzy selecting from a given shell
" command. See usage below.
function! SelectaCommand(choice_command, selecta_args, vim_command)
  try
    silent let selection = system(a:choice_command . " | selecta " . a:selecta_args)
  catch /Vim:Interrupt/
    " Swallow the ^C so that the redraw below happens; otherwise there will be
    " leftovers from selecta on the screen
    redraw!
    return
  endtry
  redraw!
  exec a:vim_command . " " . selection
endfunction

" Find all files in all non-dot directories starting in the working directory.
" Fuzzy select one of those. Open the selected file with :e.
nnoremap <leader>f :call SelectaCommand("find * -type f", "", ":e")<cr>

I'm seeing the following error in Vim (the default command line vim):

[5] benchmark.rb [ruby] [Git(master)]                                                                                                       4,3-3          Top
Error detected while processing function ruby_debugger#load_debugger..<SNR>73_check_prerequisites:                                                  
line   15:
RubyDebugger: This plugin requires +clientserver option
Error detected while processing function ruby_debugger#load_debugger:
line    2:
E168: :finish used outside of a sourced file
Error detected while processing function 289..269..<SNR>73_send_message_to_debugger:
line   11:
E121: Undefined variable: s:socket_file
E15: Invalid expression: s:socket_file
TypeError: (eval):2:in `initialize': can't convert nil into String
Press ENTER or type command to continue

I've made a symlink to selecta in /bin/. I know the default ruby version has changed to 2.0.0 but I can't figure out if I am I doing something dumb to break it or not.

Slow performance on large lists?

I got a report via Twitter that searching ~20k files is intolerably slow. A progressive search (rather than a full search each time) would at least help. There are surely many other low-hanging performance improvements.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.