Skip to content

Instantly share code, notes, and snippets.

@drewbrokke
Created December 7, 2020 19:16
Show Gist options
  • Save drewbrokke/99a2728e4fb18b8d70525d83a060a108 to your computer and use it in GitHub Desktop.
Save drewbrokke/99a2728e4fb18b8d70525d83a060a108 to your computer and use it in GitHub Desktop.
#!/bin/bash
# "sog" stands for "Show On Github"
if [ $# -lt 1 ]
then
echo "Show On Github"
echo "Enter a grep search term. Any matching paths will be opened on Github if possible."
exit
fi
SEARCH_TERM="${1:?Supply search term}"
COMMIT="$(git rev-parse upstream/master)"
(
cd "$(git rev-parse --show-toplevel)" || exit 1
COUNT=0
for FILE in $(git ls-files | grep "$SEARCH_TERM"); do
((COUNT++))
if [ $COUNT -gt 10 ]
then
break
fi
open "https://github.com/liferay/liferay-portal/blob/${COMMIT}/${FILE}"
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment