Score:0

How to create `vscode` or `code` command line by launch visual studio code from terminal?

gb flag

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.

muru avatar
us flag
If you have a solution to your problem, post an answer please, instead of putting it in the question. That said, the default Ubuntu configuration will add snap commands to the PATH, so if it doesn't, then you must have messed up something.
N0rbert avatar
zw flag
Making symlink to /usr/bin/code is bad practice. The better is to make link to /usr/local/bin/code
Henry Palacios avatar
gb flag
I did it @muru, thanks for you suggestions. I may have damaged something in **snap**, but I only had this problem with **visual studio code** with snap. Finally I left the installation I did with **ubuntu software**
Score:0
gb flag

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

Henry Palacios avatar
gb flag
I have followed @N0rbert recommendation to use `/usr/local/bin/code` instead of `/usr/bin/code`.
turbulence avatar
cn flag
@Norbert Wouldn't it be better if ```/snap/code/current/usr/share/code/bin``` be added to the PATH variable?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.