#!/usr/bin/env bash # "grep open" # # Run ripgrep to search for a pattern with the current git repo if the # current file is inside of one, otherwise the current directory. source "$HOME/.ad/lib/ad.sh" requireAd pat="$*" if [[ -z "$*" ]]; then adCtl "expand-dot" pat="$(bufRead "$bufid" dot)" fi dirname="$(git rev-parse --show-toplevel)" if [[ ! -d "$dirname" ]]; then fname="$(bufRead "$bufid" filename)" if [[ -d "$fname" ]]; then dirname="$fname" else dirname="$(dirname "$fname")" fi fi rg "$pat" "$dirname" \ --column \ --line-number \ --no-heading #cd "$dirname" || exit #rg "$pat" \ # --column \ # --line-number \ # --no-heading | # sed 's/\(.\+\):\([0-9]\+\):\([0-9]\+\):/\1:\2:\3 /g'