How to install android from my Computer terminal? I have a HTC M7 without any OS on it (it goes to black screen when I boot it). 

It doesn't have any memory card.

I am however able to have a root shell with "adb shell" when connecting it with USB.

How can I reinstall android from my computer?
You can boot into the bootloader and flash the phone with a RUU file from here or from here. Download the one suitable for your CID (Carrier ID).

adb reboot-bootloader