How to Create `Vscode` or `Code` Command Line by Launch Visual Studio Code from Terminal?

How to Create `Vscode` or `Code` Command Line by Launch Visual Studio Code from Terminal?

In Ubuntu 20.04, after download from various ways (snap or ubuntu software) the visual studio code text editor, I had not been able to find a way to install the shortcut command line vscode or code.

I used alias by open the current path:

alias c.='(code $PWD &>/dev/null &)'

But since this won't work without the line command code.

I tried the suggestions found here, to open Visual Studio Code and press Ctrl+Shift+P then type >install shell command but I got command not found.

3

1 Answer

Solution reached:

  • Find vscode_path where is visual studio code installed.
    Suppose that is /snap/code/current/usr/share/code/bin/code
  • Create a symlink from <vscode_path> bin command to /usr/bin
rm -f /usr/bin/code
ln -s /snap/code/current/usr/share/code/bin/code /usr/local/bin/code

The latter would create a code line command to launch from the terminal

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.