Every time I restart the computer the link for Atom stops working

I use the Atom editor and I like to open it from the command line. For that purpose I execute the following line:

ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom

The problem is that if I restart the computer, the link stops working, so I have to delete the file

rm /usr/local/bin/atom

and execute the first line to create the link again. I don't understand why this happens.


Solution 1:

I tried it myself and it worked perfectly, even after a reboot. Do you have multiple disks/partitions in you set up?

Anyway, to settle things once and for all, I suggest you to follow the steps pointed out here. Below is a copy&paste.

With the Atom editor open, in the menu bar:

Click Atom >> Install Shell Commands

enter image description here

You should expect to see:

enter image description here

You do not need to restart the terminal.

If this solution didn't work, my last suggestion is to create an alias in your ~/.bash_profile. To do this, simply open ~/.bash_profile with a text editor and add somewhere the line:

alias atom='open -a Atom'

This should do the trick.

EDIT

I noticed that after a reboot, you must start Atom at least once before the atom command works - otherwise it won't be recognized as a command. I didn't notice it before because, while testing if the ln -s ... solution worked, I already opened Atom once. I honestly don't have a clue why this happens, but the last suggestion about adding an alias definitely solves this issue.

Solution 2:

You might want to make sure Atom app is actually executing from the Applications folder and then install the Shell Commands utility. I was executing Atom from my Downloads folder and every time I rebooted the atom commands weren't recognized.