0

In linux mint, is it possible to run atom editor by command atom? I tried

atom
Command 'atom' is available in '/snap/bin/atom'
The command could not be located because '/snap/bin' is not included in the PATH environment variable.
atom: command not found
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
guest
  • 3

1 Answers1

1

Two solutions:

  1. Add the /snap/bin directory to you $PATH. This would give you direct access to any command in that directory.

    PATH=$PATH:/snap/bin
    

    (this would go in your ~/.bashrc file, for example).

  2. Create an alias called atom that calls /snap/bin/atom. This would replace atom with /snap/bin/atom if you used the word as a command on the command line.

    alias atom=/snap/bin/atom
    

    (this could also be added to your ~/.bashrc file).

    Instead of an alias, you could have a simple shell function that does the same thing:

    atom () { /snap/bin/atom "$@"; }
    

Changes to ~/.bashrc would be activated when you start a new shell.

Kusalananda
  • 333,661
  • why do we need to use "$@" at the end of a shell function ? what happens if we don't use it ? As I understand $@ - expands to the list of positional parameters, but we are not passing any parameters when we call atom. – HarshaD Jul 23 '19 at 15:40
  • @HarshaD To be totally honest, I have never used atom. I added the possibility to pass command line options to the function, because the alias allows it, and I didn't think it would hurt. If you want to disallow passing arguments to atom, then by all means remove the "$@" bit from the function. – Kusalananda Jul 23 '19 at 16:09
  • When launching a text editor from the command line, it's pretty common to pass parameters, in particular the filename for a file to be edited, so most often when you see shell functions, etc., to launch editors, they'll end with "$@". The main reason I'd launch a GUI text editor from the command line is to pass parameters. – bgvaughan Jul 23 '19 at 16:34