m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-17 15:53:39 -05:00

Add missing function wrapper for vf and cf

Francis T. O'Donovan
2016-05-26 12:34:55 -04:00
parent 182b65aa13
commit 2a86b754e9

@@ -32,15 +32,17 @@ fo() {
# vf - fuzzy open with vim from anywhere
# ex: vf word1 word2 ... (even part of a file name)
# 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 ]]
then
vim -- $files
print -l $files[1]
fi
if [[ -n $files ]]
then
vim -- $files
print -l $files[1]
fi
}
```
### Changing directory
@@ -84,19 +86,21 @@ fdr() {
# cf - fuzzy cd from anywhere
# ex: cf word1 word2 ... (even part of a file name)
# 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 ]]
then
if [[ -d $file ]]
then
cd -- $file
else
cd -- ${file:h}
fi
fi
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):
@@ -112,7 +116,6 @@ cdf() {
```sh
# Another CTRL-T script to select a directory and paste it into line
__fzf_select_dir ()
{
builtin typeset READLINE_LINE_NEW="$(