mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 08:13:40 -05:00
Add missing function wrapper for vf and cf
41
Examples.md
41
Examples.md
@@ -32,15 +32,17 @@ fo() {
|
|||||||
# vf - fuzzy open with vim from anywhere
|
# vf - fuzzy open with vim from anywhere
|
||||||
# ex: vf word1 word2 ... (even part of a file name)
|
# ex: vf word1 word2 ... (even part of a file name)
|
||||||
# zsh autoload function
|
# zsh autoload function
|
||||||
local files
|
vf() {
|
||||||
|
local files
|
||||||
|
|
||||||
files=(${(f)"$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1 -m)"})
|
files=(${(f)"$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1 -m)"})
|
||||||
|
|
||||||
if [[ -n $files ]]
|
if [[ -n $files ]]
|
||||||
then
|
then
|
||||||
vim -- $files
|
vim -- $files
|
||||||
print -l $files[1]
|
print -l $files[1]
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Changing directory
|
### Changing directory
|
||||||
@@ -84,19 +86,21 @@ fdr() {
|
|||||||
# cf - fuzzy cd from anywhere
|
# cf - fuzzy cd from anywhere
|
||||||
# ex: cf word1 word2 ... (even part of a file name)
|
# ex: cf word1 word2 ... (even part of a file name)
|
||||||
# zsh autoload function
|
# zsh autoload function
|
||||||
local file
|
cf() {
|
||||||
|
local file
|
||||||
|
|
||||||
file="$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1)"
|
file="$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1)"
|
||||||
|
|
||||||
if [[ -n $file ]]
|
if [[ -n $file ]]
|
||||||
then
|
then
|
||||||
if [[ -d $file ]]
|
if [[ -d $file ]]
|
||||||
then
|
then
|
||||||
cd -- $file
|
cd -- $file
|
||||||
else
|
else
|
||||||
cd -- ${file:h}
|
cd -- ${file:h}
|
||||||
fi
|
fi
|
||||||
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):
|
||||||
@@ -112,7 +116,6 @@ cdf() {
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Another CTRL-T script to select a directory and paste it into line
|
# Another CTRL-T script to select a directory and paste it into line
|
||||||
|
|
||||||
__fzf_select_dir ()
|
__fzf_select_dir ()
|
||||||
{
|
{
|
||||||
builtin typeset READLINE_LINE_NEW="$(
|
builtin typeset READLINE_LINE_NEW="$(
|
||||||
|
|||||||
Reference in New Issue
Block a user