postgresql explain analyze from sql file?
You could use cat to create a command you pass to psql. For example like this: 

psql -d database -c "explain analyze $( cat myquery.sql )"


Editing a file and adding those statements at the beginning are an option too.