Skip to content

Instantly share code, notes, and snippets.

@aldosch
Created April 17, 2024 10:16
Show Gist options
  • Save aldosch/dbc7c0553a7cef6e84ffd64d10d636d2 to your computer and use it in GitHub Desktop.
Save aldosch/dbc7c0553a7cef6e84ffd64d10d636d2 to your computer and use it in GitHub Desktop.
fif() – find in file
# find in file
fif() {
if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi
rg --files-with-matches --no-messages "$1" | fzf --preview "highlight -O ansi -l {} 2> /dev/null | rg --colors 'match:bg:yellow' --ignore-case --pretty --context 10 '$1' || rg --ignore-case --pretty --context 10 '$1' {}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment