Skip to content

Instantly share code, notes, and snippets.

@FabienArcellier
Created November 13, 2015 14:18
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 FabienArcellier/103b56022c35923985f2 to your computer and use it in GitHub Desktop.
Save FabienArcellier/103b56022c35923985f2 to your computer and use it in GitHub Desktop.
findcode & display code command
function findcode {
extension=$1
pattern=$2
find . -name "*.${extension}" | xargs grep -ni --colour=always ${pattern}
}
# Utility
function displaycode {
file=$(echo $1 | cut -f1 -d:)
line=$(echo $1 | cut -f2 -d:)
line=$(($line-10))
if [[ $line -lt 1 ]]; then
line="1"
else
echo "not"
fi
sed -n "${line}, +20p" $file
echo ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment