How to open a file with the flatpack installled Atom editor in Linux/Ubuntu

65 Views Asked by At

I installed the Atom Editor via flatpack/flathub. When I go to the command line terminal, I would like to open a file with it. This is what I see:

$ atom
Command 'atom' not found, did you mean:
  command 'adom' from snap adom (3.3.3)
  command 'atobm' from deb x11-apps (7.7+9)
  command 'atrm' from deb at (3.2.5-1ubuntu1)
  command 'atop' from deb atop (2.9.0-1ubuntu1)
  command 'atom4' from deb atom4 (4.1-9build2)
  command 'atoms' from deb horae (071~svn537+ds1-1)
See 'snap info <snapname>' for additional versions.

So, the atom editor cannot be used straight from the command line. How can I open a file with the command:

atom file.txt
1

There are 1 best solutions below

0
On

I edited the atom.desktop file and found the solution. You can find it in the application menu and edit it. The command below is the command is the same command as in the .desktop file but the %F is replaced with "$@".

If you put this in your ~/.bashrc file, then you can use the atom function to open files.

atom() {
  /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=atom --file-forwarding io.atom.Atom @@ "$@" @@
}

When you open a new Terminal, you can use this to open the file:

atom file.txt