mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 17:13:42 -05:00
Alternate fuzzy opening/cding using locate
34
Examples.md
34
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
|
||||||
|
|||||||
Reference in New Issue
Block a user