Skip to content

Instantly share code, notes, and snippets.

@amandabee
Last active August 29, 2015 13:56
Show Gist options
  • Save amandabee/9070784 to your computer and use it in GitHub Desktop.
Save amandabee/9070784 to your computer and use it in GitHub Desktop.
Run preferred syntax checker for each file type.
#!/bin/sh
# [Gedit Tool]
# Save-files=document
# Shortcut=<Primary><Shift>bar
# Output=replace-document
# Name=Tidy by filetype
# Applicability=all
# Input=document
if [ $GEDIT_CURRENT_DOCUMENT_TYPE = "text/x-python" ]; then
autopep8 - -v -a
pylint $GEDIT_CURRENT_DOCUMENT_NAME -r no > /dev/stderr
elif [ $GEDIT_CURRENT_DOCUMENT_TYPE = "text/html" ]; then
#-i auto indents, -w 80 wrap at 80 chars, -c replace font tags w/CSS
exec tidy -utf8 -i -w 100 -c "$GEDIT_CURRENT_DOCUMENT_NAME"
echo "Tidying." > /dev/stderr
#elif [ $GEDIT_CURRENT_DOCUMENT_TYPE = "text/css" ]; then
# TK: CSS Tidy
#elif [ $GEDIT_CURRENT_DOCUMENT_TYPE = "application/javascript" ]; then
# TK: JS Lint
else
#cat $GEDIT_CURRENT_DOCUMENT_NAME, then trim the blank line it added
cat -
sed -i '${/^$/d;}'
echo "This seems to be " $GEDIT_CURRENT_DOCUMENT_TYPE " I don't know how to tidy that. ..." > /dev/stderr
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment