Created
March 2, 2020 14:08
-
-
Save MousaHalaseh/80bce6cf6f4d01625008e82283032c4f to your computer and use it in GitHub Desktop.
highlighter cat
This file contains hidden or 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 | |
if [[ $# -eq 0 ]] ; then | |
echo "Please provide file path"; | |
exit 1; | |
fi | |
touch CAT_TO_PYGMENTIZE_TEMP; | |
/usr/bin/cat $1 >> CAT_TO_PYGMENTIZE_TEMP 2> /dev/null; | |
if [[ $? -ne 0 ]] ; then | |
echo "Can't read file: $1"; | |
exit 1; | |
fi | |
if [[ $1 == *".java" ]] ; then | |
mv CAT_TO_PYGMENTIZE_TEMP CAT_TO_PYGMENTIZE_TEMP.java; | |
java -jar $HOME/Downloads/google-java-format-1.7-all-deps.jar CAT_TO_PYGMENTIZE_TEMP.java | pygmentize; | |
rm CAT_TO_PYGMENTIZE_TEMP.java; | |
elif [[ $1 == *".py" ]] ; then | |
mv CAT_TO_PYGMENTIZE_TEMP CAT_TO_PYGMENTIZE_TEMP.py; | |
pygmentize CAT_TO_PYGMENTIZE_TEMP.py; | |
rm CAT_TO_PYGMENTIZE_TEMP.py; | |
else | |
/usr/bin/cat CAT_TO_PYGMENTIZE_TEMP | pygmentize; | |
rm CAT_TO_PYGMENTIZE_TEMP; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment