-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: "sift" | ||
tags: ["Tools"] | ||
layout: "post" | ||
comments: true | ||
link: false | ||
--- | ||
|
||
Some time ago I came across [sift](https://sift-tool.org/), a "fast and powerful | ||
open source alternative to [grep](https://www.gnu.org/software/grep/)". | ||
[ack](http://beyondgrep.com/) has long been my weapon of choice, but it depends | ||
on [Perl](https://www.perl.org/) while sift is distributed as a single | ||
executable. | ||
|
||
After using it as my daily driver for a couple of months I've noticed that it's | ||
a worthy competitor to [git-grep](https://git-scm.com/docs/git-grep), although | ||
the latter is still a bit faster. | ||
|
||
## Configuration | ||
|
||
sift has a feature, `--write-config`, which enables you to save your | ||
configuration directly on the command line: | ||
|
||
``` | ||
sift --smart-case --filename --line-number --group --column --git --exclude-files=tags,.gitattributes --write-config | ||
``` | ||
|
||
The `--git` flag makes it possible to ignore patterns from a project's `.gitignore` | ||
file, which is super nice. | ||
|
||
## Fuzzy file finding | ||
|
||
You can use the flag `--targets` to use sift as a fuzzy file finder: | ||
|
||
``` | ||
sift --targets --ext js | ||
``` | ||
|
||
You can also supply a pattern in order to narrow down the search: | ||
|
||
``` | ||
sift --targets --ext js test | ||
``` | ||
|
||
## Integrating with Vim | ||
|
||
To use sift in [Vim](http://www.vim.org/), configure the `grepprg` and | ||
`grepformat` options: | ||
|
||
``` viml | ||
set grepprg=sift\ --no-group\ --no-color | ||
set grepformat=%f:%l:%c:%m,%f:%l:%m | ||
``` | ||
|
||
Depending on how you've configured it you may need to add additional flags. In | ||
order for the above `grepformat` to work you have to have `--filename`, | ||
`--line-number` and `--column` enabled. | ||
|
||
To use it as an indexer for [CtrlP](https://github.com/ctrlpvim/ctrlp.vim), add | ||
this: | ||
|
||
``` viml | ||
let g:ctrlp_user_command = 'sift --no-conf --ignore-case --no-color --no-group --git --targets --path "" %s' | ||
``` | ||
|
||
And you're good to go! |