From 2bc32d54d08e994be84a61281ce6dd2b47dcea0c Mon Sep 17 00:00:00 2001 From: David Todd Date: Tue, 15 Dec 2020 12:43:23 -0600 Subject: [PATCH] Add fzf functions --- home/shell/functions | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/home/shell/functions b/home/shell/functions index dc73f79..5b3bd6e 100644 --- a/home/shell/functions +++ b/home/shell/functions @@ -61,10 +61,23 @@ up() { fi cd $d } +# Search inside files for a string # Usage: search search () { grep -r "$1" | fzf } +# Search for a file by its name +# Usage: ff (optional) +ff() { #find file + if [ -z "${2}" ]; then + find . -type f -iname "*${1}*" + else + find . -type f -maxdepth "${2}" -iname "*${1}*" + fi +} +# Search for a file by its name and edit it +# Usage: vf (optional) +vf() { vim "$(ff "$@" | fzf)"; } # Usage: replay to repeat. Blank for 1 replay() { from="${1:-2}" @@ -75,4 +88,4 @@ replay() { done fi $(fc -ln -${to} -${to}) -} \ No newline at end of file +}