Make .minecraft file read from a usb

I would not recommend storing it on a USB and playing the game from there. I would recommend transferring worlds when you need to switch computers (I'm sure you can write a script to transfer files from the USB onto the computer or the other way around). However, if you must, i would recommend looking in the Minecraft launcher settings. I am fairly certain you can change the source destination folder in there (along with allocated memory to the game and other semi-useful tweaks).

This guide may be helpful: https://www.pcsteps.com/1346-create-portable-minecraft-usb-stick/