Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vrutberg
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vrutberg/9206768 to your computer and use it in GitHub Desktop.
Save vrutberg/9206768 to your computer and use it in GitHub Desktop.
Handy .profile stuff
# finds files that by filename matches $1, does not reside in a target folder, and contains the string $2
findgrep() {
find . -name "*$1*" -and -type f -and -not -path "*/target/*" -and -not -path "*/.git/*" -print0 | xargs -0 fgrep -n --color=auto "$2"
}
# searches pom.xml files for $1
alias poms="findgrep 'pom.xml' $1"
# copies the output of the last command to the clipboard
copylast() {
fc -s | pbcopy
}
# will show you how many commits there are that matches $1
numcommits() {
git log --grep "$1" --oneline | wc -l
}
# find the first file matching $1 and copy its path to the clipboard
findcp() {
file=$(find $PWD -name "$1" | head -n 1)
echo "$file"
echo "$file" | tr -d "\n" | pbcopy
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment