4

Running flatpak list shows:

Visual Studio Code                        com.visualstudio.code                    1.55.1-1617807524     stable    system

but how is that application launched?

(The search results I've found are on how to install apps, rather than launch or run a specific app.)

2 Answers 2

7

When installed with Flatpak, you can launch VScode in the terminal by running:

flatpak run com.visualstudio.code

I recommend creating a permanent alias so that you only have to run code instead. To do this, add this line to the .bashrc file located in your home directory:

# User specific aliases and functions
alias code="flatpak run com.visualstudio.code"

Sometimes you have to use command below find the application Id

 flatpak list --columns application | grep 'visualstudio'
1

Tooling often expects that Visual Studio Code can be launched via the code command. Therefore an alias is not always sufficient.

In these cases you can create a bash script at /usr/local/bin/code with the following content and make it executable.

#!/bin/bash
flatpak run com.visualstudio.code "$@"
sudo nano /usr/local/bin/code
sudo chmod +x /usr/local/bin/code
3
  • 1
    what does the "$@" do? Commented Apr 21 at 8:33
  • @NicholasSaunders $@ expands to the positional arguments. Without it the arguments are ignored so running code --diff ~/file1 ~/file2 evaluates to just flatpak run com.visualstudio.code rather than flatpak run com.visualstudio.code --diff ~/file1 ~/file2. In this case the command just opens vscode rather than opening vscode AND diffing the two files. You can read the full description in the bash man page under Special Parameters: manpages.ubuntu.com/manpages/jammy/en/man1/bash.1.html
    – StudioLE
    Commented Apr 22 at 4:59
  • On reflection you could probably just include it in the alias, no need for my verbose answer
    – StudioLE
    Commented Apr 22 at 5:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .