Skip to content

Instantly share code, notes, and snippets.

@matthiasbeyer

matthiasbeyer/fcode

Created Mar 5, 2018
Embed
What would you like to do?
bash function to find code and open it
fcode ()
{
[ "$#" -lt 1 ] && {
echo "Supply string to search for!";
return 1
};
printf -v search "%q" "$*";
local include="yml,js,json,php,md,html,config,py,cpp,c,go,hs,rb,conf,rs,txt";
local exclude=".config,.git,node_modules,vendor,build,yarn.lock,*.sty,*.bst,*.coffee,dist,*.aux,*.tmp";
rg_cmd='rg --column --line-number --no-heading --fixed-strings --ignore-case --follow --color always';
files=$($rg_cmd $search | fzf --ansi --reverse | awk -F ':' '{print $1" +"$2}');
[[ -n "$files" ]] && ${EDITOR:-vim} $files
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.