Growing with the Web

A shell script to run Visual Studio Code in the terminal

Published , updated

Visual Studio Code was just open sourced and is still relatively new so it’s still working out some kinks such as providing a .deb package and including enhanced terminal support.

In the meantime there are a few issues with running the executable via a symlink as suggested in the official documentation that can be easily overcome. Here is a shell script that will open Visual Studio Code in the background of the terminal and pipe the output to a temp file so that the terminal is still completely usable.

nohup /path/to/vscode/Code "$@" > ~/.vscode/nohup.out 2>&1 &

To install it into your /usr/local/bin, just replace /path/to/vscode in the following script with the actual path and run it:

mkdir -p ~/.vscode
echo 'nohup '$VSCODE_PATH' "$@" > ~/.vscode/nohup.out 2>&1 &' | sudo tee /usr/local/bin/code > /dev/null
sudo chmod a+x /usr/local/bin/code

You can now run code in your terminal to launch Visual Studio Code without consuming the terminal window.


comments powered by Disqus
Like this article?
Subscribe for more!