Skip to content

Instantly share code, notes, and snippets.

@miguelbaldi
Created April 23, 2011 03:55
Show Gist options
  • Save miguelbaldi/938249 to your computer and use it in GitHub Desktop.
Save miguelbaldi/938249 to your computer and use it in GitHub Desktop.
Configuration tool for formatting javascript within gEdit (using 'External Tools' gEdit plugin)
#!/usr/bin/env python
import os
import sys
import tempfile
jsbeautifier_home = "/home/miguel/dev/javascript/js-beautify/"
content = sys.stdin.read()
h, tmpfile = tempfile.mkstemp()
os.close(h)
f = open(tmpfile, "w")
f.write(content)
f.close()
cmd = "python python/jsbeautifier.py -s 4 %s"%(tmpfile)
os.chdir(jsbeautifier_home)
content = os.system(cmd)
os.remove(tmpfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment