Created
March 5, 2018 18:46
-
-
Save matthiasbeyer/6c3631ed39847640b3e5c97518c0eae0 to your computer and use it in GitHub Desktop.
bash function to find code and open it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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