The Association of Mad Scientists

Bootstrapping a new development environment with Atom

I've recently installed Elementary OS on Owen's Macbook, which I'll be writing a post about soon. I was setting things up to work on a project when I discovered this neat trick for Atom. Atom is of course just a snap install away. To install all the packages from your old system into the new one, just run this command:

apm install $(ssh old-machine apm list --installed --enabled --bare | tr '\n' ' ')

or shortened:

apm i `ssh old-machine apm ls -ibe | tr '\n' ' '`

To explain, apm list --bare outputs a newline-separated list of packages, which tr replaces with spaces. A subprocess shell in *sh is created by either enclosing it in backticks (` – the one on the same button as ~), or parentheses prefixed by a dollar-sign ($()). In this case, the subshell remotes into the old machine, lists all the currently installed and enabled packages, and then returns the output of that text (with newlines replaced with spaces) into the apm install command.

Note that this only works if your snapd mount is in your $PATH when you run commands from a non-interactive remote shell (or you have Atom installed through non-snap means). For me, that was not the case, so I had to save the list as a text file and cat that in the ssh subshell command.