Skip to content

Instantly share code, notes, and snippets.

@bperel
Created February 12, 2020 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bperel/64606610d0c8595adbb2258e5d55de7f to your computer and use it in GitHub Desktop.
Save bperel/64606610d0c8595adbb2258e5d55de7f to your computer and use it in GitHub Desktop.
Graphviz linter
#/bin/bash
# Usage : chmod +x graphviz-linter.sh && ./graphviz-linter.sh myfile.dot
path=$1
output=''
indent=0
while read line; do
if [[ "${line:0:1}" = '}' ]]; then indent=$((indent - 1)); fi
newLine=''
for i in $(seq 1 $indent); do newLine+=' '; done
newLine+="$line"
output+="$newLine\n";
if [[ "${line: -1}" = '{' ]]; then indent=$((indent + 1)); fi
done < $path
echo -e "$output" > $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment