kieranpotts / dotfiles

My UNIX dotfiles.
MIT License
1 stars 0 forks source link

Git "find" aliases #221

Open kieranpotts opened 1 year ago

kieranpotts commented 1 year ago
# `git findpath [partial]`
#
# Find the path to the file where the name includes the given partial string.
#
# Example:
#
# ```
# $ git findpath README
# dist/README.md
# ```
#
findpath = "!git ls-files | grep -i"

Or, to search your entire codebase for a string:

grep = grep -Ii

To ensure the search is undertaken from the repository's root directory:

grep = "!f() { A=$(pwd) && TOPLEVEL=$(git rev-parse --show-toplevel) && cd $TOPLEVEL && git grep --full-name -In $1 | xargs -I{} echo $TOPLEVEL/{} && cd $A; }; f"

Source: https://www.durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/