Update README
This commit is contained in:
parent
79f645aa6c
commit
13cb198b5c
69
README.md
69
README.md
@ -13,8 +13,6 @@ Requirements
|
|||||||
|
|
||||||
fzf requires Ruby (>= 1.8.5).
|
fzf requires Ruby (>= 1.8.5).
|
||||||
|
|
||||||
*curses* gem is required for [Ruby 2.1 or above](https://bugs.ruby-lang.org/issues/8584).
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
@ -26,12 +24,11 @@ git clone https://github.com/junegunn/fzf.git ~/.fzf
|
|||||||
~/.fzf/install
|
~/.fzf/install
|
||||||
```
|
```
|
||||||
|
|
||||||
The script will generate `~/.fzf.bash` and `~/.fzf.zsh` and update your
|
The script will setup:
|
||||||
`.bashrc` and `.zshrc` to load them.
|
|
||||||
|
|
||||||
Or you can just download
|
- `fzf` executable
|
||||||
[fzf executable](https://raw.github.com/junegunn/fzf/master/fzf) and put it
|
- Key bindings (`CTRL-T`, `CTRL-R`, etc.)
|
||||||
somewhere in your search $PATH.
|
- Fuzzy auto-completion for bash
|
||||||
|
|
||||||
### Install as Vim plugin
|
### Install as Vim plugin
|
||||||
|
|
||||||
@ -150,32 +147,14 @@ fkill() {
|
|||||||
Key bindings for command line
|
Key bindings for command line
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
The install script will add the following key bindings to your configuration
|
The install script will setup the following key bindings.
|
||||||
files.
|
|
||||||
|
|
||||||
### bash
|
### bash
|
||||||
|
|
||||||
- `CTRL-T` - Paste the selected file path(s) into the command line
|
- `CTRL-T` - Paste the selected file path(s) into the command line
|
||||||
- `CTRL-R` - Paste the selected command from history into the command line
|
- `CTRL-R` - Paste the selected command from history into the command line
|
||||||
|
|
||||||
```sh
|
The source code can be found in `~/.fzf.bash`.
|
||||||
# Required to refresh the prompt after fzf
|
|
||||||
bind '"\er": redraw-current-line'
|
|
||||||
|
|
||||||
# CTRL-T - Paste the selected file path into the command line
|
|
||||||
fsel() {
|
|
||||||
find * -path '*/\.*' -prune \
|
|
||||||
-o -type f -print \
|
|
||||||
-o -type l -print 2> /dev/null | fzf -m | while read item; do
|
|
||||||
printf '%q ' "$item"
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
bind '"\C-t": " \C-u \C-a\C-k$(fsel)\e\C-e\C-y\C-a\C-y\ey\C-h\C-e\er"'
|
|
||||||
|
|
||||||
# CTRL-R - Paste the selected command from history into the command line
|
|
||||||
bind '"\C-r": " \C-e\C-u$(history | fzf +s | sed \"s/ *[0-9]* *//\")\e\C-e\er"'
|
|
||||||
```
|
|
||||||
|
|
||||||
### zsh
|
### zsh
|
||||||
|
|
||||||
@ -183,41 +162,7 @@ bind '"\C-r": " \C-e\C-u$(history | fzf +s | sed \"s/ *[0-9]* *//\")\e\C-e\er"'
|
|||||||
- `CTRL-R` - Paste the selected command from history into the command line
|
- `CTRL-R` - Paste the selected command from history into the command line
|
||||||
- `ALT-C` - cd into the selected directory
|
- `ALT-C` - cd into the selected directory
|
||||||
|
|
||||||
```sh
|
The source code can be found in `~/.fzf.zsh`.
|
||||||
# CTRL-T - Paste the selected file path(s) into the command line
|
|
||||||
fzf-file-widget() {
|
|
||||||
local FILES
|
|
||||||
local IFS="
|
|
||||||
"
|
|
||||||
FILES=($(
|
|
||||||
find * -path '*/\.*' -prune \
|
|
||||||
-o -type f -print \
|
|
||||||
-o -type l -print 2> /dev/null | fzf -m))
|
|
||||||
unset IFS
|
|
||||||
FILES=$FILES:q
|
|
||||||
LBUFFER="${LBUFFER%% #} $FILES"
|
|
||||||
zle redisplay
|
|
||||||
}
|
|
||||||
zle -N fzf-file-widget
|
|
||||||
bindkey '^T' fzf-file-widget
|
|
||||||
|
|
||||||
# ALT-C - cd into the selected directory
|
|
||||||
fzf-cd-widget() {
|
|
||||||
cd "${$(find * -path '*/\.*' -prune \
|
|
||||||
-o -type d -print 2> /dev/null | fzf):-.}"
|
|
||||||
zle reset-prompt
|
|
||||||
}
|
|
||||||
zle -N fzf-cd-widget
|
|
||||||
bindkey '\ec' fzf-cd-widget
|
|
||||||
|
|
||||||
# CTRL-R - Paste the selected command from history into the command line
|
|
||||||
fzf-history-widget() {
|
|
||||||
LBUFFER=$(history | fzf +s | sed "s/ *[0-9]* *//")
|
|
||||||
zle redisplay
|
|
||||||
}
|
|
||||||
zle -N fzf-history-widget
|
|
||||||
bindkey '^R' fzf-history-widget
|
|
||||||
```
|
|
||||||
|
|
||||||
Auto-completion
|
Auto-completion
|
||||||
---------------
|
---------------
|
||||||
|
4
install
4
install
@ -90,7 +90,7 @@ EOF
|
|||||||
bind '"\er": redraw-current-line'
|
bind '"\er": redraw-current-line'
|
||||||
|
|
||||||
# CTRL-T - Paste the selected file path into the command line
|
# CTRL-T - Paste the selected file path into the command line
|
||||||
fsel() {
|
__fsel() {
|
||||||
find * -path '*/\.*' -prune \
|
find * -path '*/\.*' -prune \
|
||||||
-o -type f -print \
|
-o -type f -print \
|
||||||
-o -type l -print 2> /dev/null | fzf -m | while read item; do
|
-o -type l -print 2> /dev/null | fzf -m | while read item; do
|
||||||
@ -98,7 +98,7 @@ fsel() {
|
|||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
bind '"\C-t": " \C-u \C-a\C-k$(fsel)\e\C-e\C-y\C-a\C-y\ey\C-h\C-e\er"'
|
bind '"\C-t": " \C-u \C-a\C-k$(__fsel)\e\C-e\C-y\C-a\C-y\ey\C-h\C-e\er"'
|
||||||
|
|
||||||
# CTRL-R - Paste the selected command from history into the command line
|
# CTRL-R - Paste the selected command from history into the command line
|
||||||
bind '"\C-r": " \C-e\C-u$(history | fzf +s | sed \"s/ *[0-9]* *//\")\e\C-e\er"'
|
bind '"\C-r": " \C-e\C-u$(history | fzf +s | sed \"s/ *[0-9]* *//\")\e\C-e\er"'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user