Skip to content

Instantly share code, notes, and snippets.

@matthiasbeyer
Created March 5, 2018 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthiasbeyer/6c3631ed39847640b3e5c97518c0eae0 to your computer and use it in GitHub Desktop.
Save matthiasbeyer/6c3631ed39847640b3e5c97518c0eae0 to your computer and use it in GitHub Desktop.
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