|
1 | 1 | # `fzf`
|
2 | 2 |
|
3 |
| -[`fzf`](https://github.com/junegunn/fzf) is a general-purpose command-line fuzzy finder. |
4 |
| - |
5 |
| -## Why use `fzf` |
6 |
| - |
7 |
| - - Speed |
8 |
| - - Rich feature set |
9 |
| - - Highly customizable |
| 3 | +[`fzf`](https://github.com/junegunn/fzf) is a general-purpose command-line |
| 4 | +fuzzy finder. On it's own it's not very useful but when combined with other |
| 5 | +tools it becomes super powerful. |
10 | 6 |
|
11 | 7 | ## Installation
|
12 | 8 |
|
13 |
| -Use [homebrew](http://sourabhbajaj.com/mac-setup/Homebrew/README.html) to install `fzf`: |
14 |
| - |
15 |
| - brew install fzf |
16 |
| - |
17 |
| -If you want to use shell extensions: |
18 |
| - |
19 |
| - /usr/local/opt/fzf/install |
20 |
| - |
21 |
| -which are: |
22 |
| - |
23 |
| - - Key bindings (`CTRL-T`, `CTRL-R`, and `ALT-C`) (available for bash, zsh and fish) |
24 |
| - - Fuzzy auto-completion (available for bash and zsh) |
| 9 | +Use [homebrew](http://sourabhbajaj.com/mac-setup/Homebrew/README.html) to |
| 10 | +install `fzf`: |
25 | 11 |
|
26 |
| -## Usage |
| 12 | + $ brew install fzf |
27 | 13 |
|
28 |
| -### Fuzzy completion |
| 14 | +If you want to use shell extensions (better shell integration): |
29 | 15 |
|
30 |
| ->hit tab (↹) after: |
| 16 | + $ /usr/local/opt/fzf/install |
31 | 17 |
|
32 |
| -#### File search |
| 18 | +which gives you: |
33 | 19 |
|
34 |
| - vim ** |
| 20 | + - Key bindings (`CTRL-T`, `CTRL-R`, and `ALT-C`) (available for _bash_, _zsh_ |
| 21 | + and _fish_) |
| 22 | + - Fuzzy auto-completion (available for _bash_ and _zsh_) |
35 | 23 |
|
36 |
| -or |
| 24 | +## Example Usages |
37 | 25 |
|
38 |
| - subl ** |
| 26 | +Add any of these functions to your shell configuration file and apply the |
| 27 | +changes to try them out. Or just paste the function in your terminal if you |
| 28 | +just want to try it out without saving it. |
39 | 29 |
|
40 |
| -#### Host name search |
| 30 | +```sh |
| 31 | +# fd - cd to selected directory |
| 32 | +fd() { |
| 33 | + local dir |
| 34 | + dir=$(find ${1:-.} -path '*/\.*' -prune \ |
| 35 | + -o -type d -print 2> /dev/null | fzf +m) && |
| 36 | + cd "$dir" |
| 37 | +} |
| 38 | +``` |
41 | 39 |
|
42 |
| - ssh ** |
| 40 | +```sh |
| 41 | +# fh - search in your command history and execute selected command |
| 42 | +fh() { |
| 43 | + eval $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//') |
| 44 | +} |
| 45 | +``` |
43 | 46 |
|
44 |
| ->**Note**: for more fuzzy search things head over [official repo](https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh) |
| 47 | +**For more fuzzy search examples see the |
| 48 | +[official repo](https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh).** |
45 | 49 |
|
46 |
| -### Chrome history from CLI |
| 50 | +### Chrome history from your terminal |
47 | 51 |
|
48 |
| ->**Note**: original [blog post](https://junegunn.kr/2015/04/browsing-chrome-history-with-fzf/) |
| 52 | +**Note**: original [blog post](https://junegunn.kr/2015/04/browsing-chrome-history-with-fzf/) |
49 | 53 |
|
50 |
| -Open up shell config (most likely `~/.zshrc` or command `zshconfig`) and add following function: |
| 54 | +Open up your shell config and add following function: |
51 | 55 |
|
52 | 56 | ```sh
|
53 | 57 | # ch - browse chrome history
|
|
66 | 70 | }
|
67 | 71 | ```
|
68 | 72 |
|
69 |
| ->**Note**: Ensure that path to `History` file is correct; read more information on [StackOverflow](https://stackoverflow.com/a/16742333/1564365) |
| 73 | +**Note**: Ensure that path to `History` file is correct; read more information |
| 74 | +on [StackOverflow](https://stackoverflow.com/a/16742333/1564365). |
0 commit comments