Skip to content

Instantly share code, notes, and snippets.

@rosswintle
Last active October 16, 2020 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rosswintle/4d74e63d9b25d1c0b0824d15dd377822 to your computer and use it in GitHub Desktop.
Save rosswintle/4d74e63d9b25d1c0b0824d15dd377822 to your computer and use it in GitHub Desktop.
Command-line (bash) code-searching functions.
# Add these to your .bashrc file for some quick and clever recursive web-dev code searching
# from the command line/terminal.
#
# Should be easy enough to add your own too.
#
# Usage is just:
#
# phprgrep <regular expression>
#
# Regular expresssions need to be escaped/quoted if you're being clever.
# This is not a tutorial on escaping stuff on the command line. Google it!
# Recursive search of PHP files
phprgrep() {
grep -r --include="*.php" --exclude="vendor/*" $1 *
}
# Recursive search of CSS files
cssgrep() {
grep -r --include="*.css" --include="*.scss" $1 *
}
# Recursive search of SCSS files
scssgrep() {
grep -r --include="*.scss" $1 *
}
alias sassgrep="scssgrep"
# Recursive search of JS files
jsgrep() {
grep -r --include="*.js" --exclude="node_modules/*" $1 *
}
# Recursive search of Statamic files
sgrep() {
grep -r --include="*.php" --include="*.yaml" --include="*.md" $1 *
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment