Created
December 7, 2020 19:16
-
-
Save drewbrokke/99a2728e4fb18b8d70525d83a060a108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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