From 2a86b754e9d4a3cdb0b6ccfe760f81a5c89d04c1 Mon Sep 17 00:00:00 2001 From: "Francis T. O'Donovan" Date: Thu, 26 May 2016 12:34:55 -0400 Subject: [PATCH] Add missing function wrapper for vf and cf --- Examples.md | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Examples.md b/Examples.md index 73efa5d..2d29f90 100644 --- a/Examples.md +++ b/Examples.md @@ -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="$(