Mercurial > dotfiles
diff dot_zshrc @ 552:f308f66cad13
Add fif (find in file) command to search for words and view in fzf
author | zegervdv <zegervdv@me.com> |
---|---|
date | Tue, 01 Feb 2022 19:03:03 +0100 |
parents | 2cce224318f9 |
children | 4b9b6694aa5b |
line wrap: on
line diff
--- a/dot_zshrc Tue Feb 01 15:22:08 2022 +0100 +++ b/dot_zshrc Tue Feb 01 19:03:03 2022 +0100 @@ -211,6 +211,20 @@ export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc export BAT_CONFIG_PATH=$HOME/.config/bat/config +# # source: https://gist.github.com/gnanderson/d74079d16714bb8b2822a7a07cc883d4 +function fif() { + rg \ + --column \ + --no-heading \ + --fixed-strings \ + --ignore-case \ + --hidden \ + --follow \ + --glob '!.git/*' "$1" \ + | awk -F ":" '/1/ {start = $2<5 ? 0 : $2 - 5; end = $2 + 5; print $1 " " $2 " " start ":" end " " $3}' \ + | fzf --preview 'bat --wrap character --color always {1} --highlight-line {2} --line-range {3}' \ + --bind 'ctrl-o:execute(nvim {1}:{2}:{4})+cancel' +} [ -f ~/.zshrc.local ] && source ~/.zshrc.local