How to Sandbox a Terminal

I often pull code from remote repositories and execute it for testing. This is an area where sandboxing would be extremely beneficial.