comparison 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
comparison
equal deleted inserted replaced
551:2cce224318f9 552:f308f66cad13
209 export HGEDITOR=nvim 209 export HGEDITOR=nvim
210 210
211 export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc 211 export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc
212 export BAT_CONFIG_PATH=$HOME/.config/bat/config 212 export BAT_CONFIG_PATH=$HOME/.config/bat/config
213 213
214 # # source: https://gist.github.com/gnanderson/d74079d16714bb8b2822a7a07cc883d4
215 function fif() {
216 rg \
217 --column \
218 --no-heading \
219 --fixed-strings \
220 --ignore-case \
221 --hidden \
222 --follow \
223 --glob '!.git/*' "$1" \
224 | awk -F ":" '/1/ {start = $2<5 ? 0 : $2 - 5; end = $2 + 5; print $1 " " $2 " " start ":" end " " $3}' \
225 | fzf --preview 'bat --wrap character --color always {1} --highlight-line {2} --line-range {3}' \
226 --bind 'ctrl-o:execute(nvim {1}:{2}:{4})+cancel'
227 }
214 228
215 [ -f ~/.zshrc.local ] && source ~/.zshrc.local 229 [ -f ~/.zshrc.local ] && source ~/.zshrc.local
216 230
217 # Must run after brew is loaded 231 # Must run after brew is loaded
218 export SUDO_EDITOR=$(which nvim) 232 export SUDO_EDITOR=$(which nvim)