junegunn / fzf Goto Github PK
View Code? Open in Web Editor NEW:cherry_blossom: A command-line fuzzy finder
License: MIT License
:cherry_blossom: A command-line fuzzy finder
License: MIT License
Currently, CTRL-T and CTRL-R won't work when vi-mode is enabled.
set -o vi
set -o
bind '"\C-x\C-e": shell-expand-line'
bind '"\C-x\C-r": redraw-current-line'
bind '"\C-t": "\ei $(__fsel)\C-x\C-e\C-x\C-r"'
bind '"\C-r": "\eddi$(HISTTIMEFORMAT= history | fzf +s | sed \"s/ *[0-9]* *//\")\C-x\C-e\C-x\C-r\e$"'
There're escape sequences for arrow keys:
up - "\027[A"
down - "\027[B"
left - "\027[D"
right - "\027[C"
Why don't use them to navigate in result list? I, personally, find it much better then ^K / ^J - one less key to press.
traversing e.g large git repositories with find is suboptimal, so it would be nice if fzf had to option to automatically use the fastest method available.
Something like this seems to work ~ an order of magnitude faster for me:
f()
{
if [ -z $(git rev-parse --abbrev-ref HEAD 2>/dev/null) ]; then
fzf $*
else
FZF_DEFAULT_COMMAND="git ls-tree -r --name-only $(git rev-parse --abbrev-ref HEAD)" fzf $*
fi
}
Hello,
I'm trying to use fzf in the GUI 2-panel file manager (double commander), it would be extermely useful.
First question: how to open xterm (or probably other terminal emulator?) with fzf opened?
I tried: xterm -e /usr/bin/ruby /path/to/fzf
, but xterm window is opened and immediately closed, I can't read anything even if it writes something. Just in case, I tried xterm -e aptitude
, it worked (xterm window is opened with aptitude), but with fzf it doesn't work.
Just by chance, I tried redirect output to the file: xterm -e /usr/bin/ruby /path/to/fzf > /tmp/my_tmp_log
, the file /tmp/my_tmp_log is not created at all (I definitely have permissions to do that, so it's not up to permissions)
Second question: how to make it actually return a value? If I execute xterm -e /usr/bin/ruby /path/to/fzf
from the already-opened terminal, new xterm window is successfully opened with fzf in it, I can select file, but after that, nothing is returned. So, how to return value?
Thanks!
In the virtual console, the match is invisible (black FG, black BG). As the match gets larger, it becomes impossible to determine which file is which.
I tried fzf today on a PC running mintty/Cygwin and on my laptop running iTerm2/OS X and had the same problem both places. The results that come up as I'm typing are corrupted until I scroll through them or type Ctrl-L. This happens in tmux if I run fzf using the Ctrl-R key binding or if I run fzf just as 'fzf' from the command line. It does NOT happen when I invoke it with the Ctrl-T key binding (which opens up a new tmux pane). It also does not happen if I run fzf outside of tmux. I tried it with my .tmux.conf completely blank and that didn't help.
On my laptop I am running zsh 5.0.5, tmux 1.9a (I also tried a newer dev build of tmux, same results), and ruby 2.0.0p451.
Any ideas?
Here's what it looks like before/after redrawing with Ctrl-L:
fish: Expected redirection specification, got token of type '$TMPDIR/fzf.result'
/home/endetti/.config/fish/functions/fish_user_key_bindings.fish
(line 16): __fzf_select > $TMPDIR/fzf.result in function '__fzf_ctrl_t', called on standard input,
http://www.reddit.com/r/vim/comments/28eh6k/fzf_vim_tmux/ciavblg
It'd be a good idea to be able to use TAB
to hit a command (instead of just ENTER
as it is now). That's for example on the command line history search.
It's hard-coded to use find, which surprised me because I'd set FZF_DEFAULT_COMMAND=ag -l -p "" and couldn't figure out why "cat " was still including my .gitignore'd files. I assume this is not intentional?
For stronger compatibility with my emacs hands :)
Great work btw!
Hi and thanks for the awesome tool!
Would it be possible to add a CTRL-Q key binding for quitting the finder?
Best regards,
Anton
Hello,
I really really love your tool except one thing it is written in ruby ;-), however, I'm fine with this. I'm working to integrate your engine to work with dmenu & i3 wm window switcher.
In i3 WM, I hit alt-d it show list of window for choose to focus which powered by dmenu (see https://github.com/ziberna/i3-py/blob/master/examples/winmenu.py) I want to do similar things with fzf.
One thing that I don't like dmenu is that it doesn't support fuzzy matching. I also don't prefer to install too many fuzzy engine on my machine.
Currently, I have slmenu, dmenu, ctrlp, and fzf. As I know you tool, I want to eliminate other tools to use one only.
PS: it work be really nice if your such tool can be written in C so the performance will be improved a lot. I don't aware if there such tools written in C
Thanks
Tai
The entries of ~/.ssh/config are not accessible.
Not sure if this is by design (I know extended-mode isn't supposed to be a full regex matcher), but thought I'd report it.
If foo
is a directory in the current directory, try fzf -x
with the following inputs:
^foo
returns all results starting with foo
, including the foo
directoryfoo$
returns nothingfoo/$
returns nothing^foo$
returns nothingTry find ${1:-*} 2> /dev/null | fzf -x
(which I use to include hidden files/directories, not sure if there's a better way):
foo$
returns all results ending with foo
, including the foo
directory^foo
returns all results starting with foo
, including the foo
directory^foo$
returns nothingI finally got around to installing fzf yesterday, and I must say it is an extremely thoughtfully-designed and pleasant experience. Nice work!
Issue 27 (#27) requested a --select-single
option to fzf to automatically select a match if there is only one.
While a workaround was provided, I think this is a common enough use case with a complex enough workaround to merit addition of the actual option.
I am using the fq1() workaround heavily, both in the shell but also in vimscript. Having to duplicate this in two places makes me wish I could just simplify both cases to a single --select-single argument.
Besides improving usability, not having to invoke fzf twice (as the workaround does) would preclude having to move large result sets around in memory and across processes, and save a second invocation of the fzf process. That could have a noticeable performance/memory improvement in some cases.
It may make sense to combine this with a --select-zero option to exit if no matches are found.
In my .inputrc, I use "set editing-mode vi". Because this puts readline into vi-mode everywhere, I don't have a "set -o vi" in my .bashrc file, which AFAIK is for making "only bash" (and not other readline-using programs) use vi bindings.
Without "set -o vi", when .bashrc sourced .fzf.bash, the set -o | grep vi check returned empty, looking like vi mode was not setup, and so the non-vi key bindings where set.
However, after .bashrc was evaluated, my .inputrc settings took affect, and if I manually run "set -o | grep vi" in a terminal, then it does actually report as on.
Basically, AFAIK, .fzf.bash is running before .inputrc, so doesn't see the "set editing-mode vi" flag.
After struggling quite awhile with trying to figure out why Ctrl-T was doing bizarre things, I finally put "set -o vi" into my .bashrc, and now things work much better.
A hint in the docs might help future users avoid this confusion. I can add something to the readme if you like, unless it's terribly obvious that anyone using "set editing-mode vi" would of course also have "set -o vi" set. (Obviously it was not obvious to me.)
How to reproduce:
I expect fzf to show me full history every time I press Ctrl+R.
Guess the thing is that fzf doesn't reread ~/.zsh_history until 'history' is executed.
UPD: Maybe this is not fzf bug, because if I disable Ctrl+R hotkey in fzf zsh behaves the same way. But anyway, it would be great, if fzf could fix that.
I use rbenv and installed 2.1.0 without curses gem.
When I installed fzf, it detected system ruby and installed well but it's not work because shebang of fzf file(#!/usr/bin/env ruby
) point to rbenv's ruby, so it couldn't load curses gem.
First of all: I love it. Much faster than CtrlP etc. when run from my home directory.
I'm wondering, how other people narrow down their search. I currently use stuff like
" ~/.vimrc
let g:fzf_source = 'find . -type f | grep -v "AppData/" | grep -v "\.git/" | grep -v "\.mat$"'
and
#~/.fzf.zsh
fzf-filter-ignored() {
grep -v "AppData/" |
grep -v "\.git/"
}
#...
FILES=($(
find * -path '*/\.*' -prune \
-o -type f -print \
-o -type d -print \
-o -type l -print 2> /dev/null | \
fzf-filter-ignored | fzf --multi --extended --no-sort))
to exclude files and dirs, which i will never want to access (.git
directories come to mind immedately).
Would it be possible to add support for some kind of .fzfignore
files, which could be used to exclude certain directories and/or files right away? I'm imagining having a global ~/.fzfignore
and then project-specific ones down the directory-tree much like git.
When I press control-T in tmux, the pane does not split and fzf does not run successfully. Pressing control-T for the first time has the equivalent result of pressing return at a blank zsh prompt (i.e. nothing happens, except a clean prompt); afterwards, pressing control-T has no visible effect.
If I set FZF_TMUX = 0 (to disable to pane split), then fzf works as intended.
I am using tmux 1.9a (tmux -V) and zsh 5.0.5 with oh-my-zsh.
Regardless of on whatever shell it may be, fzf is installable simply by placing fzf in a directory included in $PATH
. However, the install script generates an optimal function wrapper for fzf and defines some useful key bindings. It would be nice if it supports fish as well.
It would be awesome if fzf would be able to fuzzy find directories as well by providing an additional option on the command line. I'd use it to quickly navigate to a subdirectory.
When I use fzf
to find processes to kill
, as I type there are residual processes not cleared by Curses. To remedy that I have added:
C.clear
in function update_list
at the start of the render do
loop.
Great app btw, loving it :)
Thanks for building fzf! Everything's working fine, but I'm wondering what might be a good way to toggle fzf open and closed using just . Is there a hook for fzf to see if it's currently open where I could then just hit again to close it instead of reaching up for ?
When invoking fzf with zsh, the first time you select a file and hit enter the selection seems to be ignored, and you have to do it again, then it behaves as expected. Works perfectly in bash.
Command history contains plenty of duplicates usually, and these are just noise. Would be nice to have them removed from the list.
It would be very handy if fzf could perform keywords matching separated by a space " ".
For example, if we look for match of candidates that meet both conditions "foo" and "bar":
foo bar
You can also specify negative conditions with an exclamation mark "!". This matches candidates that meet "foo" but do not meet "bar":
foo !bar
Howdy,
This is a really neat project. I thought it might be helpful to add some information about how to get it running with MacVim and iTerm2, for users as inept as myself. The following script is, so far, a passible stand-in for "xterm -e". You just need to add it to your Vim's PATH as an executable titled, for example, "In_a_new_term_function" and let g:fzf_launcher = "In_a_new_term_function %s"
#!/bin/bash
osascript -e \
'on run argv
tell application "System Events"
set old_frontmost to item 1 of (get name of processes whose frontmost is true)
end tell
tell application "iTerm"
activate
set myterm to (make new terminal)
tell myterm
set mysession to (make new session at the end of sessions)
tell mysession
exec command "bash"
write text "cd " & quoted form of (item 2 of argv)
write text (item 1 of argv) & " && exit"
end tell
repeat while (exists myterm)
delay 0.1
end repeat
end tell
end tell
tell application old_frontmost
activate
end tell
end run' "$1" "$PWD"
The algorithm sorting the matches should give priority to better matches.
Example: In a repo of mine, searching for "login" finds a lot of things, selecting
"gae/brokenlinkshunter/appengine_django/management/commands/vacuum_indexes.py"
instead of
"logins.rst"
which is obviously a better match.
If I type "cat " and select a really long file name, and it wraps to the second line, then the \C-x\C-r is not sufficient to redraw the line, there is still some artifacts. It looks vaguely like:
$ ls the/really/long/
file.txt really/long
There "really/long" is repeated again after "file.txt", even though the cursor is in the right spot (at the end of the line, after "file.txt ").
I noticed that deleting a character causes the terminal to redraw the end of the line, so I added a dummy "\exa " at the end of the existing vi-mode incantation to delete/re-add the trailing space:
bind '"\C-t": "\e$a \eddi$(__fsel)\C-x\C-e\e0Px$a \C-x\C-r\exa "'
This fixes the wrapping artifact issue.
Note that I tried putting the \C-x\C-r before the "a ", thinking that redrawing the line, then appending the space after that might work, but it did not. It seems doing the delete is what kicks in the "clear the rest of the line" behavior that's needed to clear the wrapping artifact.
It looks like I'm hit with this bug: https://bugzilla.redhat.com/show_bug.cgi?id=526366
This only happens inside tmux for some reason. After running fzf a few times, it would hang the next time I start it up. strace shows that it's gpm related. I have to manually restart gpm to make it work. This effectively prevents me from using it at work, which is a shame because I love this tool so much. :(
Anyway, let me know if you happen to possess some wizardry to make this work. If not, thanks for the great plugin and I'll still continue to use it on my Macbook.
I would like to use fzf
as a kind of "selection menu", in that way dmenu
may be used. Therefore, it would be nice, if fzf
had:
fzf
has not matched anythingWhichever of these two that gets sourced first stops working. If .fzf.bash
is first, the vim ~/**<TAB>
stuff will stop working, and if the other way around git <TAB>
will stop working.
.bash_profile
# Add tab completion for many Bash commands
if [ -f "$(brew --prefix)/etc/bash_completion" ]; then
source "$(brew --prefix)/etc/bash_completion"
fi
# Enable fzf
if [ -e "$HOME/.fzf.bash" ]; then
source "$HOME/.fzf.bash"
fi
Is it possible to open the completion list directly in (G|Mac)Vim window like in CtrlP?
In a recent discussion about Zed the topic of fuzzy matching came up and I liked the idea of using multiple patterns separated by space.
In Komodo, space is treated as a logical AND, which you can use to more effectively search the above.
I imagine it like this: I have entered the search term foobar
and it's currently matching hundreds of lines beginning with foo
and ending with bar
. To match the single line foo/gunn/bar
I would just append to foobar gunn
instead of having to remove bar
.
Makes sense?
It would be extremely useful, if fzf could return plain text after running a query. I think one could use this in third-party apps to provide fuzzy search inside them.
When using i.e. HISTTIMEFORMAT the timestamps are recorded for every command. It would be really nice if there was an option to display them on the right hand side.
The only thing really stopping me from replacing ctrlp entirely with fzf is support for <C-V>
to vsplit, <C-S>
to hsplit, <C-T>
to open in a new tab, etc.
https://raw.githubusercontent.com/junegunn/i/master/fzf-commandt-ctrlp-unite.gif
I read the page and found unite.vim cache performance was too bad.
But I have improved file_rec/async performance in unite.vim.
I want to re-test for the files.
I have a script that gives me a list of issues to work on, and I wanted to use fzf to choose one. The script uses unicode arrows to denote priority, and these are not shown correctly in fzf.
Input:
PRO-2567 ↧ Do thing 1
PRO-2573 ↥ Do thing 2
PRO-2683 ⇊ Do thing 3
What fzf renders:
PRO-2567 F� Do thing 1
PRO-2573 F� Do thing 2
PRO-2683 G~J Do thing 3
If the search provides more results than fit in one screen, I am unable to scroll outside of the ones that are currently showing.
The behaviour in Sublime-Text, CtrlP etc. fuzzy-finders defaults to treating space-seperated chunks as exact-search patterns. If I have a directory structure like so for example
.
└── Projects
└── asd
├── make.m
└── Makefile
I would like to be able to enter pro asd make
in order to get to the 2 files. In extended mode however, I need to quote the chunks individually:
(desired behaviour, but typing apostophes is annoying)
(no apostrophes lead to undesired behaviour)
Would it be possible to make the default behaviour in extended mode look for exact matches? Baring that, maybe a different mode -X
, which has that behaviour?
Playing around with command lines which have non ascii characters. At some point Ctrl-r started throwing the following.
I would have sent you my history output, but there's too much sensitive data there...
Here's part of the command line which is related to the issue. However, I was playing with it for several hours before it started to cause issues, so I'm not sure that this is the origin of the issue.
select Hráč Protihráč, sum(Zabití) Zabití, sum(Smrtí) Smrtí
This is the exception:
/home/harel/.fzf/fzf:486:in `=~': incompatible encoding regexp match (UTF-8 regexp with IBM852 string) (Encoding::CompatibilityError)
from /home/harel/.fzf/fzf:486:in `trim'
from /home/harel/.fzf/fzf:405:in `format'
from /home/harel/.fzf/fzf:715:in `block (2 levels) in update_list'
from /home/harel/.fzf/fzf:709:in `each'
from /home/harel/.fzf/fzf:709:in `each_with_index'
from /home/harel/.fzf/fzf:709:in `block in update_list'
from /home/harel/.fzf/fzf:727:in `call'
from /home/harel/.fzf/fzf:727:in `block in start_renderer'
When providing a --query=foo
parameter it could be useful to select the only match immediately when there is only one. When there are multiple matches the selection happens as usual.
Could look like this:
fzf --query=foo --select-single
This is related to #26.
It would great to have an option similar to smartcase
in vim: automatically turn on case sensitivity if the pattern contains upper case characters, otherwise keep it case-insensitive. Thanks again! :)
I decided to write a small function to select tmux sessions by fuzzy name. I added the result to the Wiki: https://github.com/junegunn/fzf/wiki/examples#tmux
If you think it is useful enough to be included in the Readme, just let me know. I would create a pull request.
Also let me know if you disagree with the implementation of fs
.
Feel free to just close this issue no further action is required.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.