Skip to content

Instantly share code, notes, and snippets.

@NikkyAI
Last active July 6, 2017 03:42
Show Gist options
  • Save NikkyAI/7f8778119c5ac02ee7aee4fe8aa9775c to your computer and use it in GitHub Desktop.
Save NikkyAI/7f8778119c5ac02ee7aee4fe8aa9775c to your computer and use it in GitHub Desktop.
#!/bin/env zsh
# DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DIR=${0:a:h}
cd $DIR
mkdir -p $DIR/data
cd $DIR/data
genpactree() {
pactree $1 --graph | tee $1.dot | dot -T png -o $1.png
}
combine() {
local HEADER=`cat $1.dot | head -n 2`
local FOOTER=`cat $1.dot | tail -n 1`
local arr
arr=()
for x; do
arr+=`cat $x.dot | tail -n +3 | head -n -1`
done
BODY=$(echo ${(j:\n:)arr} | awk '!x[$0]++')
local FILENAME=${(j:_:)@}
echo $HEADER > $FILENAME.dot
echo $BODY >> $FILENAME.dot
echo $FOOTER >> $FILENAME.dot
cat $FILENAME.dot | dot -T png -o $FILENAME.png
}
genpactree dotnet
genpactree dotnet-sdk-2.0
genpactree dotnet-runtime-2.0
genpactree python
genpactree nim
genpactree zsh
combine zsh nim
combine dotnet dotnet-sdk-2.0 dotnet-runtime-2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment