You do not have to worry about all that.
The PICKIT2 has a setting that when ever it sees the hex file updated it will start programming.
So, what ever you use to compile, just have the PICKIT running in the background set up the way you want it and let it run.