mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 09:03:43 -05:00
Alternate fuzzy opening/cding using locate
38
Examples.md
38
Examples.md
@@ -26,6 +26,21 @@ fo() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# vf - fuzzy open with vim
|
||||||
|
# ex: vf word1 word2 ... (even part of a file name)
|
||||||
|
# zsh autoload function
|
||||||
|
local files
|
||||||
|
|
||||||
|
files=(${(f)"$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1 -m)"})
|
||||||
|
|
||||||
|
if [[ -n $files ]]
|
||||||
|
then
|
||||||
|
vim -- $files
|
||||||
|
print -l $files[1]
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
### Changing directory
|
### Changing directory
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -46,6 +61,25 @@ fda() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# cf - fuzzy cd
|
||||||
|
# ex: cf word1 word2 ... (even part of a file name)
|
||||||
|
# zsh autoload function
|
||||||
|
local file
|
||||||
|
|
||||||
|
file="$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1)"
|
||||||
|
|
||||||
|
if [[ -n $file ]]
|
||||||
|
then
|
||||||
|
if [[ -d $file ]]
|
||||||
|
then
|
||||||
|
cd -- $file
|
||||||
|
else
|
||||||
|
cd -- ${file:h}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
Suggested by [@harelba](https://github.com/harelba) and [@dimonomid](https://github.com/dimonomid):
|
Suggested by [@harelba](https://github.com/harelba) and [@dimonomid](https://github.com/dimonomid):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -515,7 +549,7 @@ fzf-locate-widget() {
|
|||||||
local selected
|
local selected
|
||||||
if selected=$(locate / | fzf -q "$LBUFFER"); then
|
if selected=$(locate / | fzf -q "$LBUFFER"); then
|
||||||
LBUFFER=$selected
|
LBUFFER=$selected
|
||||||
fi
|
fi
|
||||||
zle redisplay
|
zle redisplay
|
||||||
}
|
}
|
||||||
zle -N fzf-locate-widget
|
zle -N fzf-locate-widget
|
||||||
@@ -585,4 +619,4 @@ vs(){
|
|||||||
# https://github.com/D630/fzf-wrapper
|
# https://github.com/D630/fzf-wrapper
|
||||||
% . fzf-wrapper
|
% . fzf-wrapper
|
||||||
% [<ENV>...] __fzf_wrapper [<ARG>...]
|
% [<ENV>...] __fzf_wrapper [<ARG>...]
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user