I've been searching (not very hard) for a way to compile and program PICs through the command line. Finally found one. I haven't tried this out yet, but it should work with the pickit2.
I have the pickit3 so hopefully I will write an article soon showing XC8 + PK3CMD. Until then, enjoy the link for pickit2!