# Adapted from https://amitness.com/vscode-on-colab # Copy this script into a colab cell # install deps if needed !(command -v "code-server" 1>/dev/null) || (curl -fsSL https://code-server.dev/install.sh | sh && echo) !(python -c "import pyngrok" 2>/dev/null) || (pip install -qqq pyngrok) # run vscode in background if needed !(ps -ef|awk '/code-server/&&!/awk/{exit 1}') && (nohup code-server --port 9000 --auth none &) # run ngrok tunnel if needed from pyngrok import ngrok if not ngrok.get_tunnels(): ngrok.connect(port=9000) print('CONNECT:', ngrok.get_tunnels()[0].public_url) # kill ngrok & vscode !echo !kill $(ps -ef|awk '/ngrok|code-server/&&!/awk/{print $2}')