Tip on using git ls-tree (#31)

This commit is contained in:
Junegunn Choi 2014-05-02 12:52:06 +09:00
parent 7d15071c63
commit 809d465de5

View File

@ -458,6 +458,26 @@ export FZF_DEFAULT_COMMAND='ag -l -g ""'
fzf
```
### `git ls-tree` for fast traversal
If you're running fzf in a large git repository, `git ls-tree` can boost up the
speed of the traversal.
```sh
# Copy the original fzf function to __fzf
declare -f __fzf > /dev/null ||
eval "$(echo "__fzf() {"; declare -f fzf | grep -v '^{' | tail -n +2)"
# Use git ls-tree when possible
fzf() {
if [ -n "$(git rev-parse HEAD 2> /dev/null)" ]; then
FZF_DEFAULT_COMMAND="git ls-tree -r --name-only HEAD" __fzf "$@"
else
__fzf "$@"
fi
}
```
### Fish shell
It's [a known bug of fish](https://github.com/fish-shell/fish-shell/issues/1362)